new is used for method hiding and override is used for method overriding…
This is all to do with polymorphism. When a virtual method is called on a reference, the actual type of the object that the reference refers to is used to decide which method implementation to use. When a method of a base class is overridden in a derived class, the version in the derived class is used, even if the calling code didn’t “know” that the object was an instance of the derived class. For instance:
public class Base
{
public virtual void SomeMethod()
{
Console.WriteLine(“Base:: SomeMethod”);
}
}
public class Derived : Base
{
public override void SomeMethod()
{
Console.WriteLine(“Derived:: SomeMethod”);
}
}
…
Base b = new Derived();
b.SomeMethod();//output : Derived:: SomeMethod
will end up calling Derived.SomeMethod if that overrides Base.SomeMethod.
Now, if you use the new keyword instead of override, the method in the derived class doesn’t override the method in the base class, it merely hides it. In that case, code like this:
public class Base
{
public virtual void SomeOtherMethod()
{
Console.WriteLine(“Base:: SomeMethod”);
}
}
public class Derived : Base
{
public new void SomeOtherMethod()
{
Console.WriteLine(“Derived:: SomeMethod”);
}
}
…
Base b = new Derived();
Derived d = new Derived();
b.SomeOtherMethod();//output: Base::SomeMethod
d.SomeOtherMethod();//output: Derived::SomeMethod
Will first call Base.SomeOtherMethod , then Derived.SomeOtherMethod . They’re effectively two entirely separate methods which happen to have the same name, rather than the derived method overriding the base method.If you don’t specify either new or overrides, the resulting output is the same as if you specified new, but you’ll also get a compiler warning (as you may not be aware that you’re hiding a method in the base class method, or indeed you may have wanted to override it, and merely forgot to include the keyword).

good article
Comment by Thakur — September 22, 2008 @ 6:03 am
good article
good one
Comment by Thakur — September 22, 2008 @ 6:04 am
very nice article….
Comment by Ashwani — October 21, 2008 @ 10:09 am
Usefull Article
Comment by Vineeta Agarwal — December 9, 2008 @ 12:12 pm
nice article
Comment by manivel — February 16, 2009 @ 6:32 am
More Useful Things,So Good
Comment by Adarsh — May 5, 2009 @ 2:18 pm