PDA

Click to See Complete Forum and Search --> : what's this?


vbzero
May 30th, 2002, 07:01 PM
private int WordCount = 0;
private GlobalData.Word[] Word;
Word = new GlobalData.Word[WordCount];
MessageBox.Show(Word[WordCount].ToString());

Error: IndexOutOfBounds when sending the MessageBox call

why is this?

thx!

wolfofthenorth
May 30th, 2002, 07:33 PM
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.

wolfofthenorth
May 30th, 2002, 11:16 PM
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

vbzero
May 31st, 2002, 06:15 AM
sorry:

the correct syntax was

Word = new GlobalData.Word[WordCount + 1];