O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required