protected void add(params int[] arr)
    {
         int total = 0;
        foreach (int i in arr)
        {
            total += i;
        }
        
    }
above function can be called with n-number of argument.
   add(1, 2, 3, 4, 5, 6, 7, 9, 10);
   add(1, 2, 3, 4, 5, 6, 7, 9);
   add(1 );
 
No comments:
Post a Comment