Need someone to check my code. I dont get why I got an indexoutofrange error in my code.
I am trying to write a program that finds the minimum of the 2nd element of a two dimensional array, but I get an indexoutofrange error. Code below: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { double[,] cs = { { 1, 10 }, { 2, 9 }, { 3, 8 }, { 4, 7 }, { 5, 6 }, { 6, 5 }, { 7, 6 }, { 8, 7 }, { 9, 8 }, { 10, 9 }, { 11, 10 }, { 12, 11 } }; // Determine min first double minimums = 9999; for (int i = 0; i <= cs.Length; i++) { if (cs[0, i] < minimums) { minimums = cs[0, i]; } else { } } Console.WriteLine(minimums); Console.ReadLine(); } } }