Best Practice: .Net Naming convention

There are many rules in the best practice of programming naming convention. I selected just a few, so it would be easier to remember and follow.

refer to C# Coding Conventions (C# Programming Guide) from Microsoft.

  • Identifiers should have easily readible names. “FundingSource”  instead of “SourceFunding”.
  • Use CamelCase for fields and PascalCase for properties and methods.
  • Use underscore prefix for class fields. to distinguish between private variables and local fields, I use “my” prefix for private variables.
  • Note: MS recommends using “this.” to distinguish between private variables and local fields. No matter what other rules do you use, using c# “this.” or vb.net “me.” is a good habit.

Do not use in identiers:

  • non-alphanumeric characters (like underscores), try not to use numbers
  • Hungarian notation
  • abbreviations or not widely accepted acronyms
  • data type names
  • names already used in Microsoft and other commonly used namespaces

Namespaces: (Company).(Product or Component).(Feature).(Sub-Feature)

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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