The declaration format for a class is as follows:
Attributes Class-modifiers class identifier Class-base class-body;
Where attributes, Class-modifiers, Class-base, and class-body are optional. Attributes is the property set, Class-modifiers is the modifier of the class, and the keyword class follows the name Indentifier,class-base and Class-body of the class to represent the inheritance and the base class name.
Modifier for Class
The modifiers of a class can be one or both of the following (the same modifier is not allowed to appear multiple times in the declaration of a Class):
The new---only allows for use in nested class declarations, indicating that the class hides members that are inherited from the base class and that have the same name as the base class.
The public---means that access to the class is not restricted.
Internal---Only the class in which it resides.
Private---only on packages. NET to access the application or library in.
Abstract---Abstraction class, which does not allow instances of classes to be established.
Sealed---Sealed class and is not allowed to be inherited.
Using instances of a class
Use the new keyword to create an instance of a class, such as the following code:
Class a{}
class b{
void f{
a a=new a ();
}
An instance of Class A is created in method F of Class B.
Inheritance declarations for classes
We use the following code to indicate that Class B inherits from Class A:
Class a{}
Class b:a{}
For the inheritance mechanism in C # we will discuss in detail in part fourth, where it is stated that the classes in C # support only single inheritance.