C# FAQS : Class Modifiers , Static constructors , Destructors , Indexers
Class
Various class modifiers are listed below :
-
new
-
public
-
protected
-
internal
-
private
-
abstract
-
sealed
-
static
Class – new modifier
The new modifier is permitted on nested classes. It specifies that the class hides an inherited member by the same name. It is a compile-time error for the new modifier to appear on a class declaration that is not a nested class declaration.
Class – Abstract modifier
An abstract class cannot be sealed.
Class – sealed modifier
Class – static modifier
Static constructors
- A static constructor does not take access modifiers or have parameters.
- A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.
- A static constructor cannot be called directly.
- The user has no control on when the static constructor is executed in the program.
Destructors
Indexers Overview
- Indexers enable objects to be indexed in a similar way to arrays.
- A get accessor returns a value. A set accessor assigns a value.
- The this keyword is used to define the indexers.
- The value keyword is used to define the value being assigned by the set indexer.
- Indexers do not have to be indexed by an integer value; it is up to you how to define the specific look-up mechanism.
- Indexers can be overloaded.
- Indexers can have more than one formal parameter, for example, when accessing a two-dimensional array.
