Friday, May 31, 2013

Public Access Modifiers

This is the most lenient of
all the access modifier, any member of the class which is defined public can be
accessed from anywhere inside or outside of the class. Members defined with
this modifier provide no restriction in getting or setting the values.

The following example defines a public
variablestrPublicName.

classBaseClass

{

privatestring
strPrivateName;

publicstring strPublicName;

protectedstring
strProtectedName;

internalstring
strInternalName;

protectedinternalstring strProtectedInternalName;

}

//

classChildClass :
BaseClass

{

publicstring
strChildName;

}

Notice that the public variable is visible
to the object of the class, which is instantiated in an external class.