Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Why doesn't this work ?:

 

                  foreach (DataRow dr in dataTable.Rows)
                   {
                       //Nieuwe class vullen
                       cust[cust.Length + 1] = new Class_customers(Int32.Parse(dr[0].ToString), dr[1].ToString, dr[2], dr[3],

 

I'll get te following error:

 

With Int32.Parse(dr[0].ToString):

 

Methode for Int32.pars has some invalid arguments

dr[0].ToString : Argument cannot convert from 'method group' to 'string'

 

Whats wrong ? :(

Edited by PlausiblyDamp
  • Administrators
Posted

All the .ToString statements should be .ToString() - notice the () at the end.

 

Also if you know the field is of a particular type it is easier / faster to cast it correctly rather than convert ot a string and then parse it.

 

i.e.

cust[cust.Length + 1] = new Class_customers((int) dr[0], dr[1].ToString, dr[2], dr[3],...

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...