It is very important to understand when and where to use access modifiers. 
1) private
2) public
3) protected
4) internal
5) protected internal
1) private : It is visible to only the same class .You cannot access the variable from any other class, even by creating an object or by inheriting it to a child class.
eg: 
Class Parent
private Var A
2)  public : It is visible through out the project and the variable can be accessed from other project. 
eg:
Class Parent
public Var A
3) protected : It is visible inside the class. It cannot be accessed directly from other class. It has to be inherited to access it.  
eg:
Class Parent
protected Var A 
Class Child 
 Inherits Parent
base.A
4) internal : It is visible all over the project except from other project or applications 
eg:
Class Parent
internal Var A 
5) protected internal : It is visible all over the project except from other procect or applications. It can be accessed in other project only by inheriting the base class. 
eg: 
Class App1.Parent
protected internal Var A
Class App2.Child
 Inherits Appl1.Parent
base.A
I am sorry for being very short in defining. 
No comments:
Post a Comment