Learn C#, VB.net with Samples in 1 Day


Abstract / MustInherit Class
  1. can never be instantiated
  2. it is an incomplete class
C# VB.net
using System;
abstract class AC
{
    public abstract void MethodAbstract();

    public void normalMethod()
    {
        Console.WriteLine("I'm from Normal Method");
    }
}                            
MustInherit Class AC
Public MustOverride Sub MethodAbstract() Public Sub normalMethod() Console.WriteLine("I'm from Normal Method") End Sub
End Class
class DC : AC
{
    public override void MethodAbstract()
    {
        Console.WriteLine("I'm from Abstract Method");
    }
}                            
Class DC
	Inherits AC
	Public Overrides Sub MethodAbstract()
		Console.WriteLine("I'm from Abstract Method")
	End Sub
End Class
                            
class Program
{
    private static void Main()
    {
        DC ob = new DC();
        ob.MethodAbstract();
        ob.normalMethod();

        Console.ReadKey();
    }
}                            
Class Program
Private Shared Sub Main() Dim ob As New DC() ob.MethodAbstract() ob.normalMethod() Console.ReadKey() End Sub End Class

Output:

I'm from Abstract Method
I'm from Normal Method
Test your .net skills with Quiz