Abstract methods
When an instance method declaration includes anabstract
modifier, that
method is said to be an abstract method. Although an abstract method is
implicitly also a virtual method, it cannot have the modifier virtual
.An abstract method declaration introduces a new virtual method but does not provide an implementation of that method. Instead, non-abstract derived classes are required to provide their own implementation by overriding that method. Because an abstract method provides no actual implementation, the method-body of an abstract method simply consists of a semicolon.
Abstract method declarations are only permitted in abstract classes
public abstract class AbstractClass
{
public abstract
void PrintName();
}
Implementation
public sealed class AbstractImp1:AbstractClass
{
public override
void PrintName()
{
Console.WriteLine("Im Aruna");
}
}
Calling
AbstractClass abs = new
AbstractImp1();
abs.PrintName();
0 comments:
Post a Comment