public class FileStream { } public class Button { } public class String { }
IComponent
(descriptive noun), ICustomAttributeProvider
(noun phrase), and IPersistable
(adjective).IComponent
and its standard implementation, the class Component
.
public interface IComponent { } public class Component : IComponent { } public interface IServiceProvider{ } public interface IFormatable { }
public enum FileMode{ Create, CreateNew, Open, OpenOrCreate, Truncate }
[Flags] public enum Bindings { CreateInstance, DefaultBinding, ExcatBinding, GetField, GetProperty, IgnoreCase, InvokeMethod, NonPublic, OABinding, SetField SetProperty, Static }
An exception to this rule is when encapsulating a Win32 API, it's common to have internal definitions that come from a Win32 header. It's ok to leave these with the Win32 casing, which is usually all-caps.
Type GetType (string typeName) string Format (string format, object [] args)
RemoveAll(), GetCharArray(), Invoke()
Defining a property with the same name as a type can cause some ambiguity languages. It is best to avoid this ambiguity unless there is a clear justification for not doing so.
For example: System.WinForms has an Icon property even though there is an Icon class because Form.Icon is so much easier to understand than Form.FormIcon or Form.DisplayIcon etc.
However, System.WinForms.UI.Control has a color property. Because there is a Color class, the Color property was named BackgroundColor as it’s a more meaningful name that does not conflict.
Text, LastIndex, Value[5]
public delegate void MouseEventHandler(object sender, MouseEvent e);
The sender parameter represents the object that raised the event. The sender parameter is always of type object, even if it is possible to employ a more specific type.
The state associated with the event is encapsulated in an instance of an event class named e. Use an appropriate and specific event class for its type.
public delegate void MouseEventHandler(object sender, MouseEvent e);
public class MouseEventArgs : EventArgs { int x; int y; public MouseEventArgs(int x, int y) { this.x = x; this.y = y; } public int X { get { return x; } } public int Y { get { return y; } } }