Abstract Class:
Now we will discuss about abstract class in c#.net.
· Abstract class is class we cannot create object. We only use inherit
· We are only use base class. If u r use abstract method u must implement derived class
Abstract Class Declaration
abstract class devenvexe
{
}
A abstract class can contain abstract method or non-abstract method .abstract method not have implementation in abstract class .but same its have derived class
Abstract Method/Non Abstract Method:
abstract class devenvexe
{
public abstract void abstractMethod();
public void NonAbstractMethod()
{
Console.WriteLine("NonAbstract Method");
}
}
Rules:
· Abstract class not have sealed class
· Abstract class only contain abstract method
· Abstract class cannot be private
· Abstract method cant have virtual keyword.because its explicit virtuval method
· Abstract class cannot be static
Performance
In our testing, abstract classes with virtual methods have better performance than interface implementation .
No comments:
Post a Comment