The Edge

Web application development insights written for our team, but open to the development community.

Naming Conventions: .net

Published on August 21, 2010

Hungarian notation seems now to be a thing of the past, and when it is used, it seems that everything is either an oObject.  Worse, when you see it used incorrectly, such as calling some non-integer object iObject.

So, it’s time to set some new standards I say.

Drawing from sources listed below, here is a list of common name types used throughout and c# and how they should be formatted.  These seem to be in line with the conventions used within the .net platform itself.

Note that in all cases, abbreviations should be avoided (i.e. use mobileNumber instead of mobNo) and acronyms of thee or more letters should be pascal case (i.e. Html istead of HTML)

Local Variables & Parameters: Within a method or property, local variables names should describe the purpose, using camel case – beginning with a lowercase letter with the first letter of each word beginning with a capital. 

  • comment
  • posts
  • tagCount
  • ByVal categoryId
  • iLoop
  • oCategories
  • commentSave
  • Post1

Member Variables:  Variables localised to classes should be in camelcase, prefixed by an underscore (_);

  • _orderId
  • _items
  • _totalPrice
  • mDeliveryCharge
  • m_postalAddress

Properties & Public Member Variables: Use Pascal Case – beginning each word with a capital, including the first.

  • OrderId
  • Items
  • totalPrice
  • deliveryCharge
  • propPostalAddress

Methods (Functions & Subs):  Pascal case.  Begin with a verb where possible.

  • GetPosts
  • SaveCategories

Classes: Pascal case, using nouns where possible.  Do not begin the class name with an I unless followed by a lower case letter to avoid confusion with interfaces.

  • Order
  • Item
  • CreditCard
  • clsCustomer
  • Buying

Interfaces: As with classes, but beginning with a capital I.



Visual Basic Naming Conventions (MSDN)

.net Naming Conventions and Programming Standards – Best Practices

Filed under: c#, Standards,
Tags: , , , ,

Leave a Reply