A class is the most common kind of reference type. The simplest possible class declaration is as follows:
class Foo { }
A more complex class optionally has the following:
Preceding the keyword | Attributes and
class modifiers. The non-nested class
modifiers are |
Following | Generic type parameters, a base class, and interfaces |
Within the braces | Class members (these are methods, properties, indexers, events, fields, constructors, overloaded operators, nested types, and a finalizer) |
A field is a variable that is a member of a class or struct. For example:
class Octopus {string name;
public int Age = 10;
}
A field may have the readonly
modifier to prevent it from being
modified after construction. A read-only field can be assigned only in
its declaration or within the enclosing type’s constructor.
Field initialization is optional. An uninitialized field has a
default value (0
,