Ticker

6/recent/ticker-posts

Access Modifier In C#

photo: educba.com


Access Modifier In C#

Access modifiers are determined the scope of visibility for variables and methods. So in a nutshell access modifiers are keywords that control the visibility of class members and other code constructs.

Public: - Public members are accessible anywhere, inside the type (e.g. - class), outside the type, inside the assembly, outside the assembly, through the inheritance, or with the type (e.g. an instance of a class, with the type of class in case of static).

Private: - Private members are only accessible within their own type (Own class).

Protected: - Protected member is accessible only with its derived types whether it is inside the assembly or outside the assembly.

Internal: - Internal member is accessible only within the assembly by inheritance (its derived type) or by an instance of the class.

Protected Internal: - Protected internal is a type of access modifier contains protected member properties as well as internal member properties, means protected internal member accessible inside the assembly in its derived class or with the instance of the class and accessible outside the class only in its derived class.

Protected Internal Property = Protected Property (anywhere in its derived class inside or outside the assembly)+ Internal (with an instance of a class only inside the assembly)

Structures:

·        It is a collection of heterogonous value type data type

·        It helps you to make a single variable hold related data of various data type

·        The structure is used to represent a record\

Struct keyword is used for creating structure. 

Post a Comment

0 Comments