Friday, September 28, 2007

List of Access Modifiers in C#

I have been programming in C# for more than 3 years now, always I forget the specifics on keywords like access modifiers. The most commonly used access modifiers are of course 'public' and 'private', and it's pretty obvious what they mean. But for example "protected internal", I just cannot recall on top of my head what it pertains to, so just as a note, here's all of them:

Access Modifier Meaning
public Available to all classes
protected Available only to the current class or to derived classes
internal Available only to classes in the current assembly
protected internal Available only to the current class, derived classes, or classes in the current assembly
private Available only to the containing class
virtual Creates a virtual method or property that can be overriden by a subclass