Thursday, September 20, 2007

Oops Concepts(Overriding in C#)

Oops Concepts(Overriding 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 override void getvalue()
{
HttpContext.Current.Response.Write("bala1");
}
}
}

Output

test getvalue = new test1();

getvalue.getvalue();

Result:bala1

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