Overload Resolution
When multiple overloads for a method with a given name exist, one of the compiler’s duties is to figure out which method is to be called given a certain argument list. A whole set of rules exists to figure out the “best target.” Those rules largely correspond to common sense and what developers would expect to be the best match. A simple example can be given using the Math.Abs method, which has seven overloads:
public static decimal Abs(decimal value);public static double Abs(double value);public static float Abs(float value);public static int Abs(int value);public static long Abs(long value);public static sbyte Abs(sbyte value);public static short Abs(short value);
Most, if not all, readers will agree on the overload that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access