I had a problem while repeating one dimension of a two-dimensional array in a C # console application. This is the part of the game that comes up with witty answers for every time you miss a shot, or you successfully shot. Let me start with the two-dimensional boolean I made:
public static bool[,] hasResponseBeenUsedBefore = new bool[2, 11];
There are two rows in the first dimension. 1 - accompany answers when the blows are successful. And 2 - accompany the answers when missed.
In the method that I created to generate the answer, I try to iterate in the second dimension.
int usedManyTimes = 0; for (int i = 0; i < hasResponseBeenUsedBefore.GetLength(1); i++) { MessageBox.Show(i.ToString()); if (hasResponseBeenUsedBefore[2, i] == true)
I tried to get the length of the second dimension without success. Throws an IndexOutOfRangeException with the following information:
HResult: -2146233080
Exception message: the index was outside the array.
Any help on this would be greatly appreciated. Thank you for your time.
source share