I have an 2D array in C# which looks like this:
float[,] PlayerStats = {
// Lap times Track A
{ 9999.0f, 9999.0f, 9999.0f, 9999.0f, 9999.0f, 9999.0f, 9999.0f },
// Lap times Track B
{ 9999.0f, 9999.0f, 9999.0f, 9999.0f, 9999.0f, 9999.0f, 9999.0f },
// Lap times Track C
{ 9999.0f, 9999.0f, 9999.0f, 9999.0f, 9999.0f, 9999.0f, 9999.0f }
};
Now after the array got filled at runtime with other values, I would like to display for example the maximum value of Lap times Track B, but I have no clue how to find the max value of row 2 only.
Is there any easy way to achieve this?
var max = Enumerable.Range(0, PlayerStats.GetLength(1)).Max(i => PlayerStats[1, i]);