Programming Language: C# (CSharp)

Class/Type: System

Method/Function: Average

Examples at hotexamples.com: 21

System Average is a method provided by the C# programming language to calculate the average of a set of numbers. It is part of the System namespace and is a member of the Math class.

Code examples:

Example 1:

double[] numbers = { 2.5, 3.5, 4.5 };

double average = System.Math.Average(numbers);

Console.WriteLine("The average of the numbers is: {0}", average);

Example 2:

int[] grades = { 85, 90, 92, 80 };

double average = System.Math.Average(grades);

Console.WriteLine("The average grade is: {0}", average);

In Example 1, we have an array of double numbers, and we use the Average method to calculate their average. In Example 2, we have an array of integer grades, and we again use the Average method to calculate their average.

The System Average method is part of the System.Linq namespace, which is a package library within the .NET framework. This namespace provides a set of language extensions for querying data against .NET collections.

Code examples:

Example 1:

double[] numbers = { 2.5, 3.5, 4.5 };

double average = System.Math.Average(numbers);

Console.WriteLine("The average of the numbers is: {0}", average);

Example 2:

int[] grades = { 85, 90, 92, 80 };

double average = System.Math.Average(grades);

Console.WriteLine("The average grade is: {0}", average);

In Example 1, we have an array of double numbers, and we use the Average method to calculate their average. In Example 2, we have an array of integer grades, and we again use the Average method to calculate their average.

The System Average method is part of the System.Linq namespace, which is a package library within the .NET framework. This namespace provides a set of language extensions for querying data against .NET collections.

Frequently Used Methods

Frequently Used Methods

Frequently Used Methods

Related in langs

Frequently Used Methods

Related