C# Style Guide
Clases
Use
PascalCasefor class name,camelCasefor methods (confilct with .NET, but makes it consitent with the rest)public class ClientActivity { public void clearStatistics() { //... } public void calculateStatistics() { //... } }Prefix interfaces with
I(to be consistent with .NET) interfaces are nouns (noun phrases) or adjectivespublic interface IShape { } public interface IShapeCollection { } public interface IGroupable { }Name source files according to their main classes.
// Located in Task.cs public partial class Task { //... } // Located in Task.generated.cs public partial class Task { //... }Use
camelCasefor method arguments and local variablespublic class UserLog { public void add(LogEvent logEvent) { int itemCount = logEvent.Items.Count; // ... } }organize namespaces with a clearly defined structure
// Examples namespace Company.Product.Module.SubModule namespace Product.Module.Component namespace Product.Layer.Module.Group