Link to home
Start Free TrialLog in
Avatar of mte01
mte01Flag for Lebanon

asked on

Urgent: Correcting a basic syntax error

Can anyone find why the following error is occuring in the following piece of C# code:

private ArrayList tot = new ArrayList(20);
private ArrayList data = new ArrayList(20);

private void tokenizeline(String line,int i)
{
      tot[i] = line;
      StringTokenizer tk = new StringTokenizer(tot[i].ToString(),"\t");
      data[i] = new String[tk.CountTokens()];
      for(int j=0;tk.HasMoreTokens();j++)
      {
            data[i][j] = tk.NextToken();
      }
}


Error at data[i][j]: Cannot apply indexing with [] to an expression of type 'object'
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AlexFM
AlexFM

I tested this, it's OK.
Avatar of mte01

ASKER

Yess...it works.......and what I did is somethin a little bit longer:

String[] temp = new String[tk.CountTokens()];
for(int j=0;tk.HasMoreTokens();j++)
{
      temp[j] = tk.NextToken();
}
data[i] = temp;


Yours is better....Thanks!!!