Advertisement
wingman007

AverageArrayOfStrings

Sep 20th, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Strings
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[] array2 = { "dasdasd", "dasdasdsad"};
  14.             Console.WriteLine(FindAverage(array2));
  15.         }
  16.  
  17.         static double FindAverage(string[] a)
  18.         {
  19.             int sum = 0;
  20.             for (int i = 0; i < a.Length; i++)
  21.             {
  22.                 sum += a[i].Length;
  23.             }
  24.             return (double)sum / a.Length;
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement