How to convert object to integer.?
object result = cmd.ExecuteScalar();
int id = Convert.ToInt32(result);
int id = Convert.ToInt32(result);
this code gives me error..
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

int id = (int)result ;
for your reference
int i = 123; // a value type
object o = i; // boxing
int j = (int)o; // unboxing
Balaji PalaniPosted Nov 3, 2016, 7:52 AM
Aleena SaviourPosted Nov 3, 2016, 8:04 AM
Aleena SaviourPosted Nov 3, 2016, 7:52 AM
BeginnerPosted Nov 3, 2016, 7:47 AM
aditya immadiPosted Nov 3, 2016, 7:40 AM
Aleena SaviourPosted Nov 3, 2016, 7:37 AM
Salman BegPosted Nov 3, 2016, 7:32 AM
Ananth GPosted Nov 3, 2016, 7:29 AM