ARTICLE AD BOX
As this problem never gets stated as an article anywhere else, I wanted to state it here.
C# When calling a Method of a derived object it will not see the derived Methods instantly. It will firstly see and use other new Methods from the derived object. Only if there is no Method that meets the requirements it will search through the Methods of the base class and call the (possibly overriden) Method then.
I heard this from other disussions but couldn't find them afterwars.
This way of handling overriding is supposedly improves performance.
Workarounds exist but I do not find them pretty. (call the base Method, add useless parameters, idk, please add them, maybe there is a good solution)
Here is an example where this affects the code:
Number number = new Number(); ushort numberUShort = 5; number.Add(numberUShort); // This actually calls public void Add(uint numberin), although the given parameter clearly is a ushort. // C# can sadly implicitly cast the ushort to uint and therefore can use the Add(uint) Method before it even sees the Add(ushort) Method. class UNumber { public virtual void Add(ushort numberin) { Console.WriteLine("Base Method"); } } class Number : UNumber { public override void Add(ushort numberin) { Console.WriteLine("Overriding Method"); } public void Add(uint numberin) { Console.WriteLine("New Method"); } } // Output: New Method