Understanding OOP Concepts With C#
Understanding OOP Concepts With C#
Keyword Description
public Visible in the current and referencing assembly.
private Visible inside current class.
protected Visible inside current and derived class.
internal Visible inside containing assembly.
protected internal Visible inside containing assembly and descendent of the current class.
Modifier Description
sealed Class can’t be inherited by a derived class.
static Class contains only static members.
unsafe The class that has some unsafe construct likes pointers.
abstract The instance of the class is not created if the class is abstract.
Constructor
A constructor is a specialized function that is used to initialize fields or additional tasks.
All class definitions contain at least one constructor. These constructors can include a default constructor, which is a
parameter-less method with the same name as the class itself.
A class definition might also include several constructor methods with parameters, known as nondefault
constructors.
A constructor returns void but does not have an explicitly declared return type.
Classes can have multiple constructors in the form of default, parameter or both.
In C#, constructors are called using the new keyword.