static void Main(string[] args) { string numString = "123045"; long num = GetNum(numString); Console.WriteLine(num); } private static long[] ten = new long[] { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000 }; public static long GetNum(string NumString) { char[] NumArray = NumString.ToCharArray(); long Num = 0L; for (int i = NumArray.Length - 1, j = 0; i >= 0; i--, j++) { Num += (NumArray[i] - ‘0‘) * ten[j]; } return Num; }
,