Alex Rivera | Logout

What is Shadowing?

Asked 2009-03-23T15:16:17.567
35

In C# what does the term shadowing mean? I have read this link but didn't fully understand it.

Edit
Report

2 Answers

32
  • Overriding : redefining an existing method on a base class
  • Shadowing : creating an entirely new method with the same signature as one in a base class
answered 2009-03-23T15:19:22.800
-4
 private static int x = 10;


static void Main(string[] args)
    { int x = 20;
        if (Program.x == 10)
        {
            Console.WriteLine(Program.x);
        }
        Console.WriteLine(x);}

Output:

10 20

answered 2012-01-11T12:56:20.927

Your Answer