Shivprasad Koirala
.NET interview question - What is Shadowing?
By Shivprasad Koirala in ASP.NET on Apr 03 2011
  • Shivprasad Koirala
    Apr, 2011 3

    Answer:

    Shadowing is a concept of altering the behaviour of the base class member. It basically replaces complete element of the parent class like method becomes a variable.

    For example: In the below example in class1 'i' is declared as variable whereas in class2 'i' is declared as a method.

    class Program{static void Main(string[] args){class1 obj = new class1();class2 obj1 = new class2();obj1.i();                 //here i is treated as methodConsole.WriteLine(obj.i); //here i is treated as variableConsole.ReadLine();}}class class1{public int i=2;}class class2 : class1{public void i(){Console.WriteLine("Hello World");}}

    Regards,

    Please click here to see more .NET interview questions

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS