Thursday, September 20, 2007

Oops Concepts(Shadowing in C#)

Title:How to use Shoadowing in c#

namespace testbala
{
public class test
{
public test()
{
}
public virtual void getvalue()
{
HttpContext.Current.Response.Write("bala");
}
}
public class test1 : test
{
public test1()
{
}
public new void getvalue()
{
HttpContext.Current.Response.Write("bala1");
}
}
}

Output


test getvalue = new test1();
getvalue.getvalue();

Result:bala

Note:When ever going to use shadowing and overriding you should mention "Virtual" in parent class.