45 lines
770 B
C#
45 lines
770 B
C#
|
/*
|
||
|
* C# Program Illustrate Method Hiding
|
||
|
*/
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Text;
|
||
|
namespace ConsoleApplication1
|
||
|
{
|
||
|
public class Demo
|
||
|
{
|
||
|
public virtual double Area(double r)
|
||
|
{
|
||
|
return r * r;
|
||
|
}
|
||
|
public void func()
|
||
|
{
|
||
|
Console.WriteLine("Base Class");
|
||
|
}
|
||
|
}
|
||
|
public class A : Demo
|
||
|
{
|
||
|
public override double Area(double r)
|
||
|
{
|
||
|
return base.Area(r) * r;
|
||
|
}
|
||
|
public new void func()
|
||
|
{
|
||
|
Console.WriteLine("Derived Class");
|
||
|
}
|
||
|
}
|
||
|
public class Test
|
||
|
{
|
||
|
public static void Main(string[] args)
|
||
|
{
|
||
|
A o1 = new A();
|
||
|
Console.WriteLine(o1.Area(20));
|
||
|
o1.func();
|
||
|
Console.ReadLine();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
8000
|
||
|
Derived Class
|