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 base class from which all value types are derived?

1 Answers  


Is dictionary reference type c#?

1 Answers  


Can delegates be used as callbacks?

1 Answers  


What is an assembly loader?

1 Answers  


What is hierarchical inheritance in c#?

1 Answers  


What is different about switch statements in c#?

1 Answers  


Is hashset ordered c#?

1 Answers  


Write a sample code to write the contents to text file in c#?

1 Answers  


what is Diff Gram

2 Answers   HCL, Nippon,


windows c# using datagridview in edit form sql server

1 Answers  


How many types of delegates are there in c#?

1 Answers  


can you allow a class to be inherited, but prevent the method from being over-ridden?

1 Answers   Siebel Systems,


Categories