C# FAQ: How declare a pure virtual function in CSharp

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:FAQs
edit

How declare a pure virtual function in C# ?

Firstly, the class must always be declared abstract.

Secondly, the method must be declared abstract.

The following is a simple example of an abstract method:

abstract class AbstractClass
{
   public abstract void AbstractMethod();
}

Unlike pure virtual C++ methods, C# abstract methods cannot have implementations—the bodies must be empty.


Personal tools