Monday 17 February 2014

Defination..

Class:-
A class Contains the member Variables(property) & member function (Function/methods).
Memory does not allocate untill object is not created.

A member function of a class is a function that has its definition or its prototype within the class definition like any other variable.
It operates on any object of the class of which it is a member, and has access to all the members of a class for that object.Member variables are attributes of an object and they are kept private to implement encapsulation. These variables can only be accessed using the public member functions.
We can say A class is the definition of an object.
Every instance of a class (except an abstract class) is an object?


abstract class:-
The purpose of abstract class is to provide default functionality to its sub classes.
When a method is declared as abstract in the base class then every derived class of that class must provide its own definition for that method.
An abstract class can also contain methods with complete implementation, besides abstract methods.
When a class contains at least one abstract method, then the class must be declared as abstract class.
It is mandatory to override abstract method in the derived class.
When a class is declared as abstract class,
then it is not possible to create an instance for that class. But it can be used as a parameter
in a method.

Access Modifier -:

An access modifier is a keyword of the language that is used to specify the access level of members of a class.
 Different Access Modifiers in C# are Public, Private, Protected, internal, protected internal.
 Default access modifier for members of class is private.
 Namespace will not have access modifier.
 Default access modifier for class ,struct, Interface, Enum, Delegate  is Internal.
 Default access modifier for class and struct members is private.
 No access modifier can be applied to interface members and always interface members are public.
 Enum members are always public and no access modifier can be applied.

There are  following access modifiers.
 Public: When Members of a class are declared as public, then they can be accessed
1.    Within the class in which they are declared.
2.    Within the derived classes of that class available within the same assembly.
3.    Outside the class within the same assembly.
4.    Within the derived classes of that class available outside the assembly.
5.    Outside the class outside the assembly.
Internal: When Members of a class are declared as internal, then they can be accessed
1.    Within the class in which they are declared.
2.    Within the derived classes of that class available within the same assembly.
3.    Outside the class within the same assembly.
Protected: When  Members  of  a  class  are  declared  as  protected,  then  they  can  be accessed
1.    Within the class in which they are declared.
2.    Within the derived classes of that class available within the same assembly.
3.    Within the derived classes of that class available outside the assembly.
Protected internal: When Members of a class are declared as protected internal, then they can be    accessed
1.    Within the class in which they are declared.
2.    Within the derived classes of that class available within the same assembly.
3.    Outside the class within the same assembly.
4.    Within the derived classes of that class available outside the assembly.
Private: Private members of a class are completely restricted and are accessible only within the class in which  they are declared.