In this article we are going to discuss Default Access Modifier in C#. There are many blogs, articles are available on the internet regarding Default Access Modifier but in this particular article I will try to explain to you with as much as simplest and realistic examples so you can get a clear idea of the Default Access Modifier use in C#.
Default Access Modifier
In C#, the default access modifier for members (fields, methods, properties, etc.) within a class or a struct is private. For top-level types (such as classes, interfaces, structs, and enums) that are declared directly within a namespace, the default access modifier is internal.
Here's a quick summary:
Example
class MyClass
{
int myField; // private by default
void MyMethod() { } // private by default
}
class MyClass2 // internal by default
{
}