public class A
{
public virtual void Print(int count)
{
Console.WriteLine(count.ToString() + " We are in A");
}
}
public class B : A
{
public override void Print(int count)
{
Console.WriteLine(count.ToString() + " We are in B");
}
public void Print(double count)
{
Console.WriteLine(count.ToString() + " Hi Kumar.");
}
}
class Program
{
static void Main(string[] args)
{
B b = new B();
b.Print(5); // 5 Hi kumar
((A)b).Print(5); // 5 We are in B
Console.ReadKey();
A a = new A();
a.Print(5); // 5 We are in A
Console.ReadKey();
A aa = new B();
aa.Print(5); // 5 We are in B
Console.ReadKey();
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment