SiteMap  | About    

Can we create the instance for abstract classes

Why can't create object of an abstract class in C# VB.Net

No, you cannot create an instance of an abstract class because it does not have a complete implementation. The purpose of an abstract class is to function as a base for subclasses. It acts like a template, or an empty or partially empty structure, you should extend it and build on it before you can use it.

abstract class MyAbstractClass { } MyAbstractClass obj = new MyAbstractClass(); //not valid

When you try to compile the above code, you will get the Error message like: "Cannot create an instance of the abstract class or interface" .

Abstract Class and Interface

Why Cannot create instance of abstract class in C# VB.Net

An Abstract class without any implementation just looks like an Interface. The choice of whether to design your functionality as an interface or an abstract class can sometimes be a difficult one. However, there are lot of differences than similarities between an Abstract class and an Interface. More about.... Difference between Abstract Class and Interface (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.