C# Interview Questions on Access Modifiers
What are Access Modifiers in C#? In C# there are 5 different types of Access Modifiers. Public The public 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 only be accessed by code in the same class or struct. Protected The type or member can only be accessed by code in the same class or struct, or in a derived class. Internal The type or member can be accessed by any code in the same assembly, but not from another assembly. Protected Internal The type or member can be accessed by any code in the same assembly, or by any derived class in another assembly. What are Access Modifiers used for? Access Modifiers are used to control the accessibilty of types and members with in the types. Can you use all access modifiers for all types? No, Not all access modifiers can be used by all types or members in all contexts, and in some cases the accessibility of a typ...