Modifiers in C#

Here are the modifiers with description and where they are applies:

Modifier
Applies To
Description
New
Function Members
The member hides an inherited member with the same signature.
Static
All members
The member does not operate on a specific instance of the class.
Virtual
Classes and Function members only
The members can be overridden by a derived class.
Abstract
Function members only
A virtual member that defines the signature of the members, but doesn’t provide an implementation.
Override
Function members only
Members override inherited virtual or abstract members.
Sealed
Classes
Members override an inherited virtual member, but cannot be overridden by any classes that inherit from this class. Must be used in conjunction with override.
Extern
Static[dll Import] methods only
A method is implemented externally in a different language.
Public
All assembly
Can be accessed by another code in assembly or other assemblies.
Private
Same class methods, properties or struct
Type or member can be accessed only by code in the same class or struct.
Protected
Class
Accessed by code in same class or derived class.
Internal
Any member of a type, also any nested type
Item is visible only within the containing assembly.
Protected internal
An member of a type, also any nested type
Item is visible to any code within its containing assembly and also to any code inside a derived type.

Comments

Popular posts from this blog

Enable HTTP Transport Security (HSTS) in IIS 7

When to use Truncate and Delete Command in SQL

Steps To Create New Project/Team On TFS