C# String

String can be defined as an array of characters. In C#, string is an object of System.String which represents sequence of characters. Strings can be concatenated, comparison, getting substring and many more. In C#, using String and string doesn’t make …

Read moreC# String

C# Encapsulation

Encapsulation is a mechanism in which we wrap the data into a single unit called class. By Encapsulation, Data alteration is not possible through unknown sources. The data can only be accessed through getter methods. Encapsulation increases the maintenance of …

Read moreC# Encapsulation

C# Access Modifiers

C# provides various keywords to control or restrict accessibility or scope of the data. We can apply access modifiers to functions and variables. There are five access modifiers in C#: Private Protected Internal Protected internal Public Let’s see each one …

Read moreC# Access Modifiers

C# Namespace

C# Provides Concept of namespacing to organize your classes in a good manner. It makes the application easy to handle. It is like packaging of java. The System is a namespace which is used in merely every Console application. It …

Read moreC# Namespace

C# Interface

Interface can be defined as a blueprint of the class. It can only have abstract methods. It has to be implemented by a class or struct. It is mainly used to achieve full abstraction because it can’t have normal methods. …

Read moreC# Interface

C# Abstraction

Abstraction is a mechanism by which we can hide the complexities and show only functionalities. C# provides an abstract keyword to declare a class and method as abstract. In C#, Abstraction is achieved by two ways: By abstract class By …

Read moreC# Abstraction

C# Sealed

C# provides sealed keyword to apply restrictions on class and methods. If a class is defined as sealed then it can’t be inherited. If a method is defined as sealed then it can’t be overridden. This is like final keyword …

Read moreC# Sealed

C# Polymorphism

Polymorphism is the combination of two words, poly+forms which means many forms. It is a greek word . In C#, Polymorphism is achieved by mixing three mechanisms that are Inheritance, encapsulation and polymorphism. There are two types of polymorphism named …

Read moreC# Polymorphism

C# Base

C# provides a base keyword to access base class properties in the chilled class. C# Base is almost similar to the super in java. It can only be used inside instance methods and constructors. It can’t be used inside any …

Read moreC# Base

C# Method Overriding

Method overriding is the mechanism where derived class defines the same method as parent class with more functionality in the chilled class. It provides runtime polymorphism in C#. It provides specific implementation to the method which is already defined in …

Read moreC# Method Overriding

C# Member overloading

If we define two members in a class with the same name then it’s called member overloading. Advantage of member overloading is the thing that we don’t need to give different names to the members of the same meaning and …

Read moreC# Member overloading

C# Aggregation

In C#, Aggregation Represents Has-A Relationship between two objects. A field of the class defines another class to reuse this in the form of association. The class is used as an entity reference. Let’s see a simple example of Aggregation …

Read moreC# Aggregation

C# Multilevel Inheritance

In Multilevel inheritance, the class inheriting its parent class is further inherited by another class and so on. This type of inheritance is transitive that’s why the last derived class inherits all of its base classes. Let’s see a simple …

Read moreC# Multilevel Inheritance

C# Inheritance

In C#, Inheritance is a mechanism by which one object acquires all the properties of another object automatically. The object which is inheriting the other object is called chilled object while the one which is inherited is called parent object. …

Read moreC# Inheritance

C# Properties

In C#, Properties enables class to provide a public way of setting and getting values or fields of the class. Properties provides Encapsulation in the class if we make all the fields of the class private and use only properties …

Read moreC# Properties

C# enum

Enum in C# is also known as enumerations. It basically refers to a named set of constants such as months, days, seasons, etc. Enum improves type safety. They contain fixed set of constants and they can be traversed. We can …

Read moreC# enum

C# Structs

In C#, Structs are like classes but they are used to create light weight objects like color, Rectangle, etc. Structs are value type unlike classes that are reference type. Using structs is useful if you have data that is not …

Read moreC# Structs

C# Static Constructor

In C#, static constructor is the one which is used to initialize static fields. It can also be used to do the task which needs to be done once only. It is invoked automatically when a constructor is called or …

Read moreC# Static Constructor

C# static class

In C#, static class is the one which can only contain static members. It can’t be instantiated. It cannot be inherited. It can only have static constructors and cannot contain instance constructors. You don’t need a private constructor to avoid …

Read moreC# static class

C# static field

In C#, static filed is the one which belongs to the class not instance hence we don’t need to create instance to access static field. The memory is assigned only once to a static field at the time of class …

Read moreC# static field