method-hiding

C# keyword usage virtual+override vs. new

What is the difference between declaring a method in a base type "virtual" and then overriding it in a child type using the "override" keyword as opposed to simply using the "new" keyword when declaring the matching method in the child type? ...

How method hiding works in C#?

Why the following program prints B B (as it should) public class A { public void Print() { Console.WriteLine("A"); } } public class B : A { public new void Print() { Console.WriteLine("B"); } public void Print2() { Pr...

How method hiding works in C#? (Part Two)

The following program prints A:C(A,B) B:C(A,B) (as it should) public interface I { string A(); } public class C : I { public string A() { return "A"; } public string B() { return "B"; } } public class A { public virtual void Print(C c) { Console.WriteLine("A:C(" + c.A() +...

does Inheritance really hide methods?

I am getting the following Compiler Warning: 'Resources.Foo.GetType()' hides inherited member 'object.GetType()'. Use the new keyword if hiding was intended. Resources.NET\Resources\Class1.cs 123 20 Resources for this (very simplified) code: public interface IFoo { int GetType(); string GetDisplayName(); } public class ...

C# and method hiding

Per MSDN, the "new" keyword when used for method hiding only suppresses a warning. http://msdn.microsoft.com/en-us/library/435f1dw2.aspx Do I really need this "new" keyword to perform method hiding? If I have a child class that has the same method name but doesn't explicitly state that it is overriding, isn't that the same thing ess...

How to use method hiding (new) with generic constrained class

I have a container class that has a generic parameter which is constrained to some base class. The type supplied to the generic is a sub of the base class constraint. The sub class uses method hiding (new) to change the behavior of a method from the base class (no, I can't make it virtual as it is not my code). My problem is that the 'ne...

Overriding vs method hiding

Possible Duplicate: Overloading,Overriding and Hiding? i am a bit confuse with the overriding vs hiding a method in C# so some bodu could please elaborate me on this please ... also the practical use knowledge of these will be appreciated and in what situation we my feel need of this? Even i am confuse with overriding why do...