C Sharp

Pascal Casing and Camel Casing

Although it's been impossible to pin down the C# team on a "hard" standard, it is obvious from their writings that they're following the notation set forth by fellow Microsoft employee Rob Caron, who suggests using a mixture of Pascal and camel casing when naming variables. In his paper "Coding Techniques and Programming Practices," available at MSDN (http://msdn.microsoft.com/library/techart/cfr.htm), he suggests using Pascal casing on method names where the first character is capitalized and camel casing on variable names. Because C# contains more elements than just methods and variables, in the following sections I've listed the different elements and the naming conventions that I've seen Microsoft use internally and that I've chosen to use as well.

NOTE
For more information on this topic, you can refer to the .NET Framework guidelines included in the .NET Framework SDK documentation under .NET Framework Developer Specifications\.NET Framework Design Guidelines\Naming Guidelines.

Namespaces

Use your company or product name, and employ mixed casing with an initial capital letter-for example, Microsoft. If you're in the business of selling component software, create a top-level namespace that is the same as your company name and then for each product, create a nested namespace with its embedded types, which will prevent name collision with other products. An example of this can be found in the .NET Framework SDK: Microsoft.Win32. This strategy might result in more long-winded names, but remember that the users of your code need only specify the using directive to save typing. If your company is called Trey Research, and you sell two products-a grid and a database-name your namespaces TreyResearch.Grid and TreyResearch.Database.

by BrainBellupdated
Advertisement: