Naming Conventions
C# Coding Standards and Naming Conventions
public class SendMailService { public void SendMail() { //... } public async Task<bool> SendMailAsync() { //... } }public class AccountController { public Add(UserViewModel userViewModel) { var result = new GenericResult(int); //... }// Correct int counter; string name; // Avoid int iCounter; string strName;// Correct public static const string ShippingType = "DropShip"; // Avoid public static const string SHIPPINGTYPE = "DropShip"; public static const string SHIPPING_TYPE = "DropShip";// Correct UserGroup userGroup; Assignment employeeAssignment; // Avoid UserGroup usrGrp; Assignment empAssignment; // Exceptions CustomerId customerId; XmlDocument xmlDocument; FtpHelper ftpHelper; UriPart uriPart;HtmlHelper htmlHelper; FtpTransfer ftpTransfer; UIControl uiControl;// Correct DateTime modifiedDate; TimeSpan deltaTime; // Avoid public DateTime modified_date; public TimeSpan delta_time; // Exception private DateTime _modifiedDate;// Correct string firstName; int lastIndex; bool isSaved; // Avoid String firstName; Int32 lastIndex; Boolean isSaved;public class Employee {} public class BusinessLocation {}public interface IShape {} public interface ITicketService {}namespace Company.Product.Module.SubModule {} namespace Product.Module.Component {} namespace Product.Layer.Module.Group {}class Program { static void Main(string[] args) { } }public class Account { public static string BankName; public static decimal Reserves; public DateTime DateOpened {get; set;} public decimal Balance {get; set;} // Constructor public Account() { // ... } }// Correct public enum Color { Red, Green, Blue } // Exception [Flags] public enum Dockings { None = 0, Top = 1, Right = 2, Bottom = 4, Left = 8 }// Don't public enum Direction : long { North = 1, East = 2, South = 3, West = 4 } // Correct public enum Direction { North, East, South, West }// Don't public enum CoinEnum { Penny, Nickel, Dime } // Don't [Flags] public enum DockingsFlags { None = 0, Top = 1, Right = 2, Bottom = 4, Left = 8 } // Correct public enum Coin { Penny, Nickel, Dime } // Correct [Flags] public enum Dockings { None = 0, Top = 1, Right = 2, Bottom = 4, Left = 8 }public class ThresholdReachedEventArgs : EventArgs {} public delegate void ThresholdReachedEventHandler(object sender, ThresholdReachedEventArgs e); public class ApiException : System.Exception {}
Offical Reference
Naming Conventions for ASP.NET Controls
Standard Controls
Data Controls
Validation Controls
Last updated