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");
}
}
}
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
Post a Comment