Jelmer Posted February 5, 2006 Posted February 5, 2006 (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 February 5, 2006 by PlausiblyDamp Quote
Administrators PlausiblyDamp Posted February 5, 2006 Administrators Posted February 5, 2006 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],... Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jelmer Posted February 5, 2006 Author Posted February 5, 2006 Stupid me.. :o But it works.. thank you ! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.