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

How do partial classes work in c#?

0 Answers  


What will be the output of the following code?

0 Answers  


What is sorted list in c#?

0 Answers  


Explain acid rule of thumb for transactions in c#.

0 Answers  


What is dataset and dataadapter in c#?

0 Answers  






Is struct object oriented?

0 Answers  


What is c sharp language?

0 Answers  


What are circular references? How garbage collection deals with circular references.

0 Answers  


What is a thread? What is multithreading?

0 Answers  


What does console writeline do?

0 Answers  


what is the difference between int and Int32?

5 Answers   TCS,


How do I open the console?

0 Answers  


Categories