Abstract Classes and Abstract Methods in C#.NET
Abstract Classes:
Abstract Classes:
- Provide default functionality to its sub classes.
- Contain methods with complete implementation, besides abstract methods.
- Contains at least one abstract method, then the class must be declared as abstract class.
//Abstract class
abstract class <Class Name>
{
protected float <Var Name>;
//Abstract methods can have only declarations
public abstract <DataType> <Method Name>();
///Method with Paramenter
public abstract <DataType> <Method Name>(<DataType> obj);
}
abstract class <Class Name>
{
protected float <Var Name>;
//Abstract methods can have only declarations
public abstract <DataType> <Method Name>();
///Method with Paramenter
public abstract <DataType> <Method Name>(<DataType> obj);
}
class <Class Name(child Class)> : <Class Name(Parent Name)>
{
public Override <DataType> <Method Name>();
{
/// Write your Code
}
public Override <DataType> <Method Name>(<DataType> obj);
{
/// Write your Code
}
}
{
public Override <DataType> <Method Name>();
{
/// Write your Code
}
public Override <DataType> <Method Name>(<DataType> obj);
{
/// Write your Code
}
}