Thursday, 20 June 2013

Difference between override and new in C#

Difference between override and new in C#

At the time of overloading we generally use override with virtual. When we need to override the base class method into derived class than we use override keyword.

The difference between override and new is that override extend the method of base class with new definition but new hides the method of base class.

Before understanding the difference between both first we have to understand their use.

Concept of New Keyoword

For Example:-

Create the following base class

public class baseClass
{
    public string ShowHello()
    {

        return "Base Class hello";
   
    }

1 comment:

  1. very simple and very clear concept , Thanks :)

    ReplyDelete