error CS0266: Cannot implicitly convert type 'object' to 'int'. An explicit conversion exists (are you missing a cast?)
int dd= 6000;
sqlCmdDefaultTime = new SqlCommand("myQuery", sqlCon);
sqlDefaultTime = sqlCmdDefaultTime.ExecuteReader();
while (sqlDefaultTime.Read())
{
dd= sqlDefaultTime[1];
}
how can i cast
Simple cast to int
:
dd = (int)sqlDefaultTime[1];
Try this...
int.TryParse(sqlDefaultTime[1].ToString(), out dd);
in the event that the parse is successful dd
will now be a new value.
Unless of course the object is an int already, the you can just cast it...
dd = (int)sqlDefaultTime[1];
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