When we retrieve data from a int field from a datatable and if I write
lValue = (long)dtTable.Rows[0]["Fld1"]
it generates an error at runtime. whereas it should be done because we are
converting int to long which should be possible.
but if I use Convert.ToInt64 it does give any error.
What is reason for that?
Regards,
Lalit Bhatia
Patrice - 25 May 2005 12:46 GMT
What if you try :
lValue = (long)(int)dtTable.Rows[0]["Fld1"]
else post the error message and see if you can repro the problem for us with
simple code such as :
object o;
int intValue=10;
long longValue;
o=intValue;
//longValue=(long)o; fails
longValue=(long)(int)o; // works
MessageBox.Show(longValue.ToString());
longValue=Convert.ToInt64(o);
MessageBox.Show(longValue.ToString());
Patrice

Signature
> When we retrieve data from a int field from a datatable and if I write
> lValue = (long)dtTable.Rows[0]["Fld1"]
[quoted text clipped - 6 lines]
> Regards,
> Lalit Bhatia