标签:static -- int stat turn ons char ring 转换
C# 不用系统自带的方法将字符串类型123456转换为值类型
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; }
C# 不用系统自带的方法将字符串类型123456转换为值类型
标签:static -- int stat turn ons char ring 转换
原文地址:https://www.cnblogs.com/heyangyi/p/8809870.html