Virtual Classes Logo          Virtual Classes
    Read Anytime,Anywhere

Class

A class is a blueprint or template to build a specific type of object. Every object is built from a class. Each class should be designed and programmed to accomplish one, and only one thing.
Think about classes as idli maker.The idli maker itself is not a idli. You can't eat the idli maker (or at least wouldn't want to) but when you create idli from it (instantiate it), Then edli is an instance created from idli maker. You can create Semolina idli or Rice idli or any other kind of idli from idli maker. You can create as many idli as you would like using the same idli maker. Likewise, you can instantiate as many instances of a class as you would like.

Class Syntex-
Class Syntex

The following sample code illustrates a sample class in C#:

Class Example

Class declaration: Line of code where the class name and type are defined.
Access keywords define the access to class members from the same class and from other classes.
The most common access keywords are:
Public: Allows access to the class member from any other class.
Private: Allows access to the class member only in the same class.
Protected:Allows access to the class member only within the same class and from inherited classes.
Internal:Allows access to the class member only in the same assembly.
Protected internal:Allows access to the class member only within the same class, from inherited classes, and other classes in the same assembly.
Static: Indicates that the member can be called without first instantiating the class.