error CS0022: Wrong number of indices

Discussion in 'Questions (Windows Mobile)' started by DaveW, Nov 18, 2008.

  1. DaveW

    DaveW Active Member Licensed User

    I have some code that works fine in the IDE but gives errors when I try to compile. I can't see what is wrong - or really understand what the error means, can anyone help?

    The error I get is:
    error CS0022: Wrong number of indices in [], expected '1'

    The code is:
    sub globals
    Public Type(GName,X,Y)CompSource

    sub writefile
    FileOpen(f,fname,cRandom)
    bin.New1(f,False)

    bin.WriteSingle(ArrayLen(CompSource()))
    For i = 0 To ArrayLen(CompSource())-1
    bin.WriteString(CompSource(i).GName) '<-- error here
    bin.WriteSingle(CompSource(i).X)
    bin.WriteSingle(CompSource(i).Y)
    Next
     
  2. wolfgang

    wolfgang Member Licensed User

    Hi,
    I think this should work:
    Code:
    Public Type(GName,X,Y)CompSource[B](0)[/B]
     
  3. DaveW

    DaveW Active Member Licensed User

    Thank you Wolfgang, You are quite right :)

    David.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    I don't understand. CompSource is an array?
     
  5. DaveW

    DaveW Active Member Licensed User

    Hi Erel,

    yes, later it gets dimmed as an array. It's probably logical that I should have dimmed it as such in the global sub but the IDE never complained and it worked fine so I never thought about it again.

    David.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice