Access modifier specify the accessibility of a variable or and object. That means who can access the object and how can it be accessed.which controls whether they can be used from other code in your assembly or other assemblies. You can use the following access modifiers to specify the accessibility of a type or member when you declare it:
public :
The type or member can be accessed by any other code in the same assembly or another assembly that references it.
private:
The type or member can be accessed only by code in the same class or struct.
protected:
The type or member can be accessed only by code in the same class or struct, or in a class that is derived from that class.
internal:
The type or member can be accessed by any code in the same assembly, but not from another assembly. Internal types or members are accessible only within files in the same assembly.
protected internal:
The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. Access from another assembly must take place within a class declaration that derives from the class in which the protected internal element is declared, and it must take place through an instance of the derived class type. "procted internal" member (combination of these two) will be visible only to classes that derive from the class that declares that member *and* are declared in a file in the same assembly.
/\____ Does it clear something???
Class and Struct Accessibility
Classes and structs that are declared directly within a namespace (in other words, that are not nested within other classes or structs) can be either public or internal. Internal is the default if no access modifier is specified.
Lets watch some videos to make it more clear :
No comments:
Post a Comment
Thank you for Commenting Will reply soon ......