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 |
What is the advantage of constructor in c#?
Why do we use interfaces in c#?
Does c# have its own class library?
What is string class in c#?
localization using windows c#
Why do we need singleton class in c#?
Why do we need singleton pattern in c#?
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.
What does console writeline do?
Why do we use constructors in c#?
Define Abstract Class in C#
Is python easier than c#?