hi
how to resolve this error
c# Cannot implicitly convert type 'long' to 'int'. An explicit conversion exists (are you missing a cast?)
hi
how to resolve this error
c# Cannot implicitly convert type 'long' to 'int'. An explicit conversion exists (are you missing a cast?)
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.
EamonnPosted Jul 27, 2009, 4:04 PM
This cannot be done without an explicit cast, and is very risky as it can result in unpredictable results.
To do an explicit cast you can do this.
However, if longVariable exceeds the maximum allowed value for an Int32, this will not thrown an overflow exception, but will set integerVariable to -1.
Another way of doing it is to use the System.Convert class which will throw an OverFlowException.