Write Extension method Average C#

  Uncategorised

Well I started with my extension method Average:

   public static double Average(this IEnumerable<int> source)
    {
        IList<int> list = source as IList<int>;
        if (source == null) throw new ArgumentNullException("Err");
        long sum = 0;
        long count = 0;
        for (int i = 0; i < list.Count; i++)
        {
            
        }
    }

My problem is that I cannot use ElementAt. I don’t want to use the Linq library

Source: Visual Studio Questions

LEAVE A COMMENT