C.2 Naming C# events
Delegate
delegate void Mouse EventHandler (object sender , MouseEvent e ); Event argument class names should end with EventArgs . For example:
public class My
EventArgs
: EventArgs{...}
|
C.3 Naming C# enums
Use Pascal
enum Day {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
It is not recommended to add Enum after the enum identifier. In the case above, Day would be more appropriate than DayEnum . Enum names should be singular “ Day is preferable to Days (it is obvious that an enum type will represent multiple items). |
C.4 Naming C# interfaces
Interface identifiers should start with an '
I
'. For example,
ISerializable
is preferable to
Serializable
as an interface
Unlike class identifiers (which should be noun phrases), interface identifiers can be either noun phrases or adjectives (phrases describing behavior). Examples of suitable adjectives include IFormatable and ISerializable .
It is okay to name interface/class pairs (a class that is
|
C.5 Naming C# properties
If you choose to use the same name for a public or protected property which 'represents' a private field in a C# class, they should be differentiated by capitalization. The public/protected property
1: private string name ; // private field name 2: 3: public string Name { // property Name 4: get{ 5: return name; 6: } 7: set { 8: name = value; 9: } 10: } |
C.6 Naming namespaces
Like Java package
While Java recommends that you name your Java packages using your company's allocated domain name on the world wide web, Microsoft recommends that you name your C# namespaces like this: <CompanyName>.<TechnologyName> For example, a class written by Addison-Wesley's technical department can be placed into the AddisonWesley.TechDept namespace. TechDept can be further divided into multiple namespaces based on the project title. Additional notes
|