Answers for "how to get highest value in array c#"

C#
7

find the max number in an array c#

// Find the max number of this Array using C# build in function
WriteLine("Find the max number of this Array using C# build in function" + Environment.NewLine+ "{ 1,2,3,4,5,6,7,8,9}");
int[] array = new[] { 1,2,3,4,5,6,7,8,9};
var maxNumber = array.Max();
WriteLine($"Max Number Of this Array:{maxNumber}");
Posted by: Guest on August-19-2021
9

find largest number in array c#

int biggest = list[0];//list refer to your list's name
for(int i = 1;i < list.Count;++i)
{
	if(list[i] > biggest)
    {
     	biggest = list[i]; 
    }
}
//now biggest will be the biggest number of the list
Posted by: Guest on March-05-2021
2

c# array max

----------------------------------------------------
  HIGHEST
----------------------------------------------------
var highest 0;
var index;
var x = 0;
int[] arry = new int[]{1,2,3,4,5,6,7,8};

foreach (dynamic i in arry)
{
  if (i > highest){ highest = i; index = x; }
  x++;
}
----------------------------------------------------
  OR
----------------------------------------------------
using System.Linq;

int maxValue = anArray.Max();
----------------------------------------------------

  
  
  
----------------------------------------------------
  LOWEST
----------------------------------------------------
var highest = 100000000000;
var index;
var x = 0;
int[] arry = new int[]{1,2,3,4,5,6,7,8};

foreach (dynamic i in arry)
{
  if (i < highest){ highest = i; index = x; }
  x++;
}
----------------------------------------------------
Posted by: Guest on February-16-2021

Code answers related to "how to get highest value in array c#"

C# Answers by Framework

Browse Popular Code Answers by Language