Take the 2-minute tour ×

I have read about virtual methods in C#. Is there any concept called virtual class in C#? Is abstract class in c# and virtual class in c++ the same?

Thanks in advance.

share|improve this question
What do you mean by a virtual class in C++? Do you mean virtual inherentance or a class with a pure virtual function? –  shf301 Feb 27 '13 at 4:23
add comment

3 Answers

up vote 6 down vote accepted

There is no such thing in C# - and it's really not necessary since multiple implementation inheritance is not supported. Making a class abstract really only means that you cannot create instances of that class and they might not be fully implemented (e.g. might contain abstract methods).

share|improve this answer
add comment

There are no virtual classes in C#. Abstract class is not the same since you cannot instantiate an abstract class.

You can do the opposite of marking something virtual by marking it sealed, which prevents it from being inherited.

share|improve this answer
add comment

I will opine with a link to this earlier SO post: In C++ what is a virtual base class?

As others have mentioned, since C# does not have multiple inheritance, the need to have a "virtual base class" that limits multiple inheritance is not needed, hence it does not apply to C#. Only members in C# can be virtual.

share|improve this answer
add comment

Your Answer


