Category Archives: C#

When to use abstract class and when to use interface

By | January 1, 2018

When to use abstract class and when to use interface This question can be asked in many different ways, situation/scenario when to choose one over another. Abstract Class can be used in situation: When you want to declare feilds and assign default value to it, go for abstract class over interface. For E.g.: When i… Read More »

Inheritance in C# With Example

By | December 17, 2017

Inheritance in C# With Example? Let’s start with the concept Inheritance in C# with example, Inheritance is the concept in which one type (class/interface) derives data member and member functions from another type is called as inheritance. The type which derives the members from another type is called as derived type and the type from… Read More »

Advantage of abstract class over Interface in C#.Net

By | December 12, 2017

Advantage of abstract class over Interface in C#.Net Adding new functions/methods to existing interface is difficult as compared to adding it to abstract class. If you want to add a new functions/methods to existing interface, you must have to implement the new functions in all of the classes that implement the changed interface. The code… Read More »

Abstract Class Vs Interface in C#.Net

By | December 10, 2017

Abstract Class Vs Interface in C#.Net Abstract Class Vs Interface in C#.Net Memebers Allowed Abstract as well as non abstact allowed. Only abstract members are Allowed. Implementation of methods in derived classes Not necessary to implement all the methods of base (abstract) class for derived classes. The derived class must implement all the methods of… Read More »

What is Interface in C#.net ?

By | December 10, 2017

What is Interface in C#.net Interface is a type which contains only the signatures/declaration of methods/functions, delegates or events. Declaration /signature of methods meaning method having no implementation as follows, void Display(string name); //By Default interface member is Public It does not contain implementation of methods. Implementation of the methods is done by the class… Read More »

Abstract Class in C#

By | December 9, 2017

Abstract Class in C# a) Classes can be declared as abstract class by using abstract keyword. b) Abstract class is designed to act as a base class (to be inherited by other classes).Abstract class is a design concept in program development and provides a base upon which other classes are built. c) Abstract class does not allow… Read More »

Interview Questions on Inheritance in C#.Net

By | November 19, 2017

Interview Questions on Inheritance in C#.Net 1) What is inheritance hierarchy? In Inheritance, The class which derives fundamental functionality from base class (Parent class) is called as derived class (Child class). This derived class can also be act like base class for another class. There for, it is possible to create tree-like structure that illustrates… Read More »

Advantages of method Overloading in C#.Net

By | November 19, 2017

Advantages of method Overloading in C#.Net Or When/Why to Use Method Overloading in C#.Net Suppose you get one program to create a method which can do sum of two numbers, three numbers & four numbers by passing parameters. So you will end up writing following methods, Public void SumTwoNumbers(int a, int b) { } Public… Read More »

Polymorphism in .Net and Types of Polymorphism in .Net

By | November 18, 2017

Polymorphism in .Net and Types of Polymorphism in .Net Polymorphism means having more than one form. It means same operation may behave differently on different classes. It is classified into compile time polymorphism or early binding or static binding and Runtime polymorphism or late binding or dynamic binding. 1) Static/early Binding /Compile Time Polymorphism: The mechanism… Read More »

What is Encapsulation

By | November 17, 2017

What is Encapsulation? Abstraction Vs Encapsulation It’s wrapping of data members and functions into a single unit called as class. An encapsulated object is often called an abstract data type. Advantage: Encapsulation can protect your data from accidental corruption Example: Let’s take example of substring() function which returns the string based on the start index and… Read More »