new and** virtual** Keyword are the same as i feel,since new Keyword in the method hides the same base class methods whereas virtual keyword override the base class,So what is difference between new and virtual ,and how to determine when to use anyone of it?
[CODE]
public class Base123
{
public void add()
{
Console.WriteLine ("Hi tis is A");
}
public virtual void a()
{
Console.WriteLine ("Hi its Base");
}
}
class Derived123:Base123
{
public new void add()
{
Console.WriteLine ("Hi this B");
}
public override void a()
{
Console.WriteLine ("Hi its derived");
}
public static void Main (string[] args)
{
Derived123 d=new Derived123(5);
d.add ();
d.a();
}
}
[/CODE]