CSharp/C# Tutorial - C# Classes






A class is the most common kind of reference type.

The class is the blue print for objects.

The simplest possible class declaration is as follows:


class YourClassName { 
} 

Preceding the keyword class we can add Attributes and class modifiers to the class.

The non-nested class modifiers are public, internal, abstract, sealed, static, unsafe, and partial.

Following YourClassName we can add Generic type parameters, a base class, and interfaces.

Within the braces Class members we can define methods, properties, indexers, events, fields, constructors, overloaded operators, nested types, and a finalizer.





Static Classes

A class can be marked static, indicating that it must be composed solely of static members and cannot be subclassed.

The System.Console and System.Math classes are examples of static classes.