Wednesday, 26 June 2013

Passing Default value to a Function in C#

  int i= Sum(10, 5);       // Positional arguments as "normal"
           i=Sum(b: 5);        // Use the default value for a
           i=Sum(a: 5);        // Use the default value for b
           i=Sum();            // Default both parameters
           i= Sum(b: 1, a: 10); //
 int Sum(int a = 9, int b = 4)
    {
        return a + b;
    }

No comments:

Post a Comment