Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Nov 9, 2012, 4:07 AM EST
As you may not have learned LINQ yet, I've used 'traditional' code to work out the average:
Shen Hengbin94 reputationPosted Nov 8, 2012, 7:37 PM EST
class Program
{
static void Main(string[] args) {
var values = new double[] { 1,2,3,4,5 };
Console.WriteLine(Average(values));
Console.Read();
}
static double Average(double[] values) {
if (values == null || values.Length == 0)
throw new ArgumentException("Parameter is null or empty");
return values.Average();
}
}
ahmed sami50 reputationPosted Nov 9, 2012, 2:49 AM EST
ahmed sami50 reputationPosted Nov 9, 2012, 4:19 AM EST
you are amazing !!