daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {      
  7.         Console.WriteLine(Sum(1, 2, 3, 4, 5));
  8.         Console.WriteLine(SumWithoutParams(new int[] {1, 2, 3, 4, 5}));    
  9.     }
  10.    
  11.     public static int Sum(params int[] numbers)
  12.     {
  13.         var sum = 0;
  14.         foreach (var n in numbers) { sum += n; }
  15.         return sum;
  16.     }
  17.    
  18.     public static int SumWithoutParams(int[] numbers)
  19.     {
  20.         var sum = 0;
  21.         foreach (var n in numbers) { sum += n; }
  22.         return sum;
  23.     }
  24. }
RAW Paste Data
Top