Prashant Verma
static void Main(string[] args){Console.Write(sum(1, 2));Console.Read();}public static int sum(int a, int b){return a + b;}public static int sum(int a, int b, int c = 3){return a + b + c;}will it work ? if yes, then which method ? if no, then runtime error / compile time error ?
By Prashant Verma in .NET on Nov 09 2015
  • Prashant Verma
    Nov, 2015 9

    Output : 3yes it will work.Ref MSDN : if two candidates are judged to be equally good, preference goes to a candidate that does not have optional parameters for which arguments were omitted in the call. This is a consequence of a general preference in overload resolution for candidates that have fewer parameters.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS