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 does yield return work c#?

0 Answers  


What is the difference between field and property in c#?

0 Answers  


What is session and cookies in c#?

0 Answers  


What is delay signing..??

1 Answers   HCL,


What is string pool in c#?

0 Answers  






Why c# is called type safe language?

0 Answers  


What is the use of private constructor in c#?

0 Answers  


What are c# types?

0 Answers  


what is the purpose of interface in c#.net

6 Answers  


Can hashtable have duplicate keys?

0 Answers  


Is predicate a functional interface?

0 Answers  


Can a string be null c#?

0 Answers  


Categories