using System.Linq; double[] numbers = { 1.0, 2.0, 3.0, 4.0, 5.0 }; double average = numbers.Average();
using System.Collections.Generic; using System.Linq; class Person { public string Name { get; set; } public double Height { get; set; } } ListIn this example, we create a list of people and use the Average method to calculate the average height of all the people in the list. The package library used in the above examples is `System.Linq`.people = new List (); people.Add(new Person { Name = "John Doe", Height = 1.8 }); people.Add(new Person { Name = "Jane Smith", Height = 1.65 }); people.Add(new Person { Name = "Bob Johnson", Height = 1.9 }); double averageHeight = people.Average(p => p.Height);