Base Class and Derived Class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BaseDerived
{
class Program
{
static void Main(string[] args)
{
BaseClass bc = new BaseClass();
bc.fn();
BaseClass bcd = new DerivedClass();
bcd.fn();
DerivedClass d = new DerivedClass();
d.fn();
Console.ReadLine();
}
}

class BaseClass
{
public virtual void fn()
{
Console.WriteLine("Base");
}
}

class DerivedClass: BaseClass
{
public override void fn()
{
Console.WriteLine("Derived");
}
}
}

Comments

Popular posts from this blog

Network Security: LAN manager authentication level

Cisco AnyConnect Secure Mobility Client - VPN service not available. The VPN agent service is not responding