Language-Specific Keywords

What’s the best way to specify the type of type members?

Use language aliases when specifying the type of fields, properties, and methods. For instance, use int instead of Int32 or System.Int32.

Using this convention is best because it’s more common and natural. Additionally, code editors render language-specific types in a different color. This improves code readability.


// Valid C#, but not ideal.
private Int32 age;

// The preferred method.
private int age;

// Alternative approach that includes a type suffix in the method name.
// Works, but not great since the type doesn't match the method name.
public int GetDataInt32()
    return ...

// Better.
public Int32 GetDataInt32()
    return ...

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s