Skip to main content

Posts

Showing posts from April, 2010

C# Coding Standards - and Naming Conventions

C# Coding Standards - and Naming Conventions Why: consistent with the Microsoft's .NET Framework and easy to read. use PascalCasing for class names and method names. publicclassClientActivity { publicvoid ClearStatistics()     { //...     } publicvoid CalculateStatistics()     { //...     } } use camelCasing for method arguments and local variables publicclassUserLog { publicvoid Add(LogEvent logEvent)     { int itemCount = logEvent.Items.Count; // ...     } }  Do not use Hungarian notation or any other type identification in identifiers // Correct int counter; string name; // Avoid int iCounter; string strName; Why: consistent with the Microsoft's .NET Framework and Visual Studio IDE makes determining types very easy (via tooltips). In general you want to avoid type indicators in any identifier. Do not use Screaming Caps for constants or readonly variables // Correct publicstaticconststring ShippingType = "DropShip"; // Avoid publicstaticconststring SHIPPINGTYPE = "DropShip"; Why: consiste…