What is hiding in CSharp ?



What is hiding in CSharp ?..

Answer / deep

Hiding is also called as Shadowing. This is the concept of Overriding the methods. It is a concept used in the Object Oriented Programming.
E.g.
public class ClassA {
public virtual void MethodA() {
Trace.WriteLine("ClassA Method");
}
}
public class ClassB : ClassA {
public new void MethodA() {
Trace.WriteLine("SubClass ClassB Method");
}
}
public class TopLevel {
static void Main(string[] args) {
TextWriter tw = Console.Out;
Trace.Listeners.Add(new TextWriterTraceListener(tw));

ClassA obj = new ClassB();
obj.MethodA(); // Outputs “Class A Method"

ClassB obj1 = new ClassB();
obj.MethodA(); // Outputs “SubClass ClassB Method”
}
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What is func c#?

0 Answers  


What does f mean in c#?

0 Answers  


If you define a user defined data type by using the struct keyword, is it a value type or reference type?

0 Answers  


What is datatable and dataset in c#?

0 Answers  


What is difference between throw and throws in c#?

0 Answers  


Are c# destructors the same as c++ destructors?

0 Answers  


What does dbml mean?

0 Answers  


Can we have private constructor in our class file. When we are trying to create instance for the class will it create or throw error regarding that?

5 Answers  


What is append in c#?

0 Answers  


What is mvc pattern in c#?

0 Answers  


What is Bubble Event ?

2 Answers   HCL,


What is .net c#?

0 Answers  


Categories