Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace task2
- {
- public static class ArrayExtensios
- {
- public static int SumArray(this int[] a)
- {
- int res = 0;
- foreach (int item in a)
- res += item;
- return res;
- }
- }
- class Program
- {
- public static void Main (string[] args)
- {
- int[] array = new int[]{ 10, 20, 30, 90, 80, 70 };
- int res = array.SumArray();
- Console.WriteLine ("Sum of array's items = {0}", res);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment