c# correct way to cast long to int code example
Example 1: c# long to int
int result = Convert.ToInt32(long value);
Example 2: c# convert long to int
// wraps around
int myIntValue = unchecked((int)myLongValue);
// throws OverflowException
Convert.ToInt32(myValue);