Results 1 to 4 of 4

Thread: what's this?

  1. #1

    Thread Starter
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347

    Question what's this?

    Code:
    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!

  2. #2
    Addicted Member wolfofthenorth's Avatar
    Join Date
    Jan 2001
    Location
    Tatooine
    Posts
    169
    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.
    Last edited by wolfofthenorth; May 30th, 2002 at 07:36 PM.
    That which does not kill us, only makes us stronger.

  3. #3
    Addicted Member wolfofthenorth's Avatar
    Join Date
    Jan 2001
    Location
    Tatooine
    Posts
    169
    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.
    That which does not kill us, only makes us stronger.

  4. #4

    Thread Starter
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347
    sorry:

    the correct syntax was

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width