Names of Type Members
Types contain the following kinds of members:
The guidelines in this section help class library designers select names for members that are consistent with the .NET Framework.
Names of Methods
Do give methods names that are verbs or verb phrases.
Typically methods act on data, so using a verb to describe the action of the method makes it easier for developers to understand what the method does. When defining the action performed by the method, be careful to select a name that provides clarity from the developer's perspective. Do not select a verb that describes how the method does what it does; in other words, do not use implementation details for your method name.
Names of Properties
Do name properties using a noun, noun phrase, or an adjective.
Noun phrases or adjectives are appropriate for properties because properties hold data.
Do not use properties that match the names of Get methods.
For example do not name a property EmployeeRecord and also name a method GetEmployeeRecord. Developers will not know which member to use to accomplish their programming task.
Do name Boolean properties with an affirmative phrase (CanSeek instead of CantSeek). Optionally, you can also prefix Boolean properties with Is, Can, or Has, but only where it adds value.
Consider giving a property the same name as its type.
When you have a property that is strongly typed to an enumeration, the name of the property can be the same as the name of the enumeration. For example, if you have an enumeration named CacheLevel, a property that returns one of its values can also be named CacheLevel.
Names of Events
Do name events with a verb or a verb phrase.
Do give event names a concept of before and after, using the present and past tense. For example, a close event that is raised before a window is closed would be called Closing and one that is raised after the window is closed would be called Closed.
Do not use Before or After prefixes or suffixes to indicate pre and post events.
Do name event handlers (delegates used as types of events) with the EventHandler suffix.
Do use two parameters named sender and e in event handler signatures.
The sender parameter should be of type, and the e parameter should be an instance of or inherit from .
Do name event argument classes with the EventArgs suffix.
Names of Fields
The naming guidelines for fields apply to static public and protected fields. You should not define public or protected instance fields. For more information, see.
Do use Pascal casing in field names.
Do name fields with nouns or noun phrases.
Do not use a prefix for field names. For example, do not use g_ or s_ to distinguish static versus non-static fields.
Portions Copyright 2005 Microsoft Corporation. All rights reserved.
Portions Copyright Addison-Wesley Corporation. All rights reserved.
For more information on design guidelines, see the "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries" book by Krzysztof Cwalina and Brad Abrams, published by Addison-Wesley, 2005.