Error: IndexOutOfBounds when sending the MessageBox callCode:private int WordCount = 0;
private GlobalData.Word[] Word;
Word = new GlobalData.Word[WordCount];
MessageBox.Show(Word[WordCount].ToString());
why is this?
thx!
Printable View
Error: IndexOutOfBounds when sending the MessageBox callCode:private int WordCount = 0;
private GlobalData.Word[] Word;
Word = new GlobalData.Word[WordCount];
MessageBox.Show(Word[WordCount].ToString());
why is this?
thx!
Is there a redim (or equivalent) in C#? I think you might need to set the array boundaries and then pick a specific index to set. Or don't declare it as an array.
I think there are a couple possible problems.
1. private GlobalData.Word[] Word;
Word has been declared as an array, but not been given any dimensions. In VB it would need a redim Word(0) command
2. Word = new GlobalData.Word[WordCount];
What is GlobalData.Word[0]? Has it been dimensioned elsewhere? Or is it a type that you are creating and setting the Word variable equal to?
Are you looking for something like...
Word[0] = New GlobalData.Word;
Hope this helps. :D
sorry:
the correct syntax was
Word = new GlobalData.Word[WordCount + 1];