public int Reverse(int x) { var s = x.ToString(); var len = s.Length; if(len == 1){ return x; } var result = string.Empty; if(s[0] == '-'){ result = -; for(var i = 1;i < len; i++){ result += s[len-i]; } }else{ for(var i = 0;i < len; i++){ result += s[len-i-1]; } } var r = 0; Int32.TryParse(result,out r); return r; }