My C# code looks like this:
myNum = dt.Columns[0];
myNum is an integer and dt is a datatable. The value in column 0 of dt is a string ("12"), but I'd like to convert it to an integer. How can I do this? I've tried:
myNum = int.Parse(dt.Columns[0]);
...but that doesn't work. Any ideas?
The values are stored in rows and not columns. Try this instead:
myNum = int.Parse(dt.Rows[0][0].ToString());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With