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 the advantage of constructor in c#?

0 Answers  


Why do we use interfaces in c#?

0 Answers  


Does c# have its own class library?

0 Answers  


What is string class in c#?

0 Answers  


localization using windows c#

2 Answers  






Why do we need singleton class in c#?

0 Answers  


Why do we need singleton pattern in c#?

0 Answers  


1. What is lazy loading? 2. What is delay signing? 3. How to transfer view object to presenter in MVP? 4. How to create a generic class? 5. What is Ajax object? 6. What is explicit interface implementation? 7. I1, I2 interfaces have same methods (say PrintName) explicitly implemented in class C1. Now how to call PrintName method from I1? 8. I have a list of Customers. List the customer with maximum orders using LINQ.

1 Answers   Aptron, Volvo,


What does console writeline do?

0 Answers  


Why do we use constructors in c#?

0 Answers  


Define Abstract Class in C#

0 Answers   HCL,


Is python easier than c#?

0 Answers  


Categories