Category «C#»

How one constructor call another constructor?

To call one C# constructor from another, before the body of the constructor, use either: : base (parameters) to call a constructor in the base class; or: : this (parameters) to call a constructor in this class. The following examples illustrate how to call one constructor from another. public class Supervisor : Employee { public …

What is Jagged Arrays?

In both the C and C++ languages, each subarray of a particular multi-dimensional array must have identical dimensions. In other words, arrays must be orthogonal. However, in both the Java and C# languages, arrays need not be orthogonal; because, arrays are constructed as arrays of arrays. In C#, each array is one-dimensional. Therefore, jagged arrays …

What is Enum?

The enum keyword is used to declare an enumeration, a distinct type consisting of a set of named constants called the enumerator list. Every enumeration type has an underlying type, which can be any integral type except char. The default underlying type of the enumeration elements is int. By default, the first enumerator has the …

Method Hiding vs Method Overriding in C#?

Method Overriding is a language feature that allows a sub class  to provide a specific implementation of a method that is already provided by its super class. The implementation in the subclass overrides (replaces) the implementation in the superclass. The important thing to remember about overriding is that the method that is doing the overriding is …

What is Method Hiding?

Method hiding in C# is similar to the function overriding feature in C++. Functions of the base class are available to the derived class. If the derived class is not happy, one of the functions available to it from the base class can define its own version of the same function with the same function …

What is Polymorphism?

Polymorphism allows objects to be represented in multiple forms. Even though classes are derived or inherited from the same parent class, each derived class will have its own behavior. Polymorphism is a concept linked to inheritance and assures that derived classes have the same functions even though each derived class performs different operations. Polymorphism is …

What is Data Hiding?

Data hiding is linked to encapsulation; however data hiding is not encapsulation as it is sometimes described in this way. Data hiding is simply the means to remove direct access to an object’s information, by providing operations that perform actions on the data. This way any changes to the value of the data must come …