C# : Abstract class : Part 11
- It is not possible to create instance / object of abstract class
- An abstract class can be only used as base class
- It cannot be sealed.
- Abstract class can have fields.
- Class derived from abstract class must provide implementation of all abstract class members.
e.g.
namespace AbstractClass
{
public abstract class Abstract1
{
public abstract int AddNumbers(int a, int b);
}
public class Class1 : Abstract1
{
public override int AddNumbers(int a, int b)
{
return a + b;
}
}
class Program
{
static void Main(string[] args)
{
Class1 objClass1 = new Class1();
var result = objClass1.AddNumbers(8, 4);
Console.WriteLine("The result is {0}", result);
}
}
}
No comments