This is a bit of a confusing question. Let me break it down into smaller questions.
What is inheritance?
When one type inherits from another, the inheritable members of the base type are also members of the derived type. Most members are inheritable; a few, like constructors, are not.
All members? Even private ones?
Yes. Private members are inherited. It may not be legal to look them up by name, but they are still inherited.
In C#, what is overloading a method?
A method is overloaded when there are two methods of the same name but different signatures in one type. (For the purposes of this discussion, the signature of a method consists of its name, generic arity, number of parameters, and parameter types.)
If we have a type D that has two members, M(X) and M(Y), that are overloaded, it is perfectly fine for one of them to be inherited from a base type B, and the other declared in D. They are still overloads.
In C#, how are overloads resolved?
The process is complex, but the basic rules are: first a collection of all accessible methods of the given name is assembled. Then all methods where the signatures do not match the given arguments are removed. The remaining methods are the applicable methods.
Then the methods that are declared in the most derived type are identified and kept; the rest of the applicable methods are removed. (Overridden methods are considered to be methods of the type which originally declared the method, not the type which overrode them.)
If one method remains, it wins. Otherwise, every pair of applicable methods is evaluated to see whether one is better than the other at matching the arguments; any method that is worse than another is eliminated. If this process produces a unique best method then it wins.
There are many more rules involving generic methods and tiebreakers that are not relevant to this discussion.
In C#, what is hiding by name for methods?
If you have a method M(X) in the base class that is inherited by the derived class, the derived class may declare another member of the same signature. This member hides the member in the base class.
In particular, if the hiding method is an applicable method then overload resolution will choose the hiding method over any base type member because, as we already know, overload resolution discards members that were not in the most derived type. Since a hiding method is always in a more derived type than the hidden method, it always wins -- provided it is accessible of course.
In C# how do we mark a member as hiding by name?
You are not required to do anything; simply declaring the member hides the base class member. However, the C# compiler will warn you that the hiding might be unintentional; it often is. You can make the warning go away by using the new
keyword on the hiding member. This is the best practice when you intend to hide a member.
In C#, what happens if overload resolution cannot pick a hiding method because it is inapplicable or inaccessible?
Then the usual rules of overload resolution apply. The hiding method is not applicable, so it is removed from the set of methods under consideration immediately. This could mean that no methods declared in the derived type are applicable, and therefore members of the base class might be the applicable methods declared in the most derived type.
Is the rule for how member shadowing works in VB slightly different than the hiding rules in C#?
Yes.
Why?
C# and VB, though deliberately similar, are not different costumes on the same actor. They're different languages with different histories, different design considerations, and different design teams. You should expect small differences like this.
So what is the difference between hiding a method and overloading a method in C#?
Both declare a new member. Adding a new overload adds a method with a different signature, and the methods might or might not be declared in the same type. Hiding a method adds a new method that exactly matches the signature of a method in a base type.