public static void Main()
Console.WriteLine("----------foreach loop----------");
Console.WriteLine($"1. Total : {total}");
total = Program.Sum(1, 3, 4);
Console.WriteLine($"2. Total : {total}");
total = Sum(1, 2, 3, 4, 5);
Console.WriteLine($"3. Total : {total}");
int[] numbers = { 6, 7, 8, 9, 10 };
Console.WriteLine($"4. Total : {total}");
Console.WriteLine($"5. Total : {total}");
Console.WriteLine("\n----------for loop----------\n");
Console.WriteLine($"1. Total : {total}");
total = Program.Sum1(1, 3, 4);
Console.WriteLine($"2. Total : {total}");
total = Sum1(1, 2, 3, 4, 5);
Console.WriteLine($"3. Total : {total}");
int[] numbers1 = { 6, 7, 8, 9, 10 };
Console.WriteLine($"4. Total : {total}");
Console.WriteLine($"5. Total : {total}");
public static int Sum(params int[] numbers)
foreach (int number in numbers)
public static int Sum1(params int[] numbers)
for (int i = 0; i < numbers.Length; i++)