while(x!=0)
{
try
{
result = checked(result *10);
result += x%10;
x/=10;
}
catch (System.OverflowException e)
{
return 0;
}
}
return result;