Reputation: 3824
I have a database , and I use ADO.net to get data from it , so I used a SQL Data adapter to fill my data in Datatable DT. I have an Attribute float x , I want to parse a column in my DT to float here's the code :
foreach (DataRow row in DT.Rows)
{
x = float.Parse(row[6].ToString()F),
}
it highlights the F in red and tells me The Name F does not exist in the current context syntax error , ',' expected .
thanks
Upvotes: 2
Views: 73
Reputation: 726669
it tells me can't convert type
object
tofloat
Use Convert.ToSingle()
method instead:
foreach (DataRow row in DT.Rows) {
x = Convert.ToSingle(row[6]);
}
Upvotes: 1