/// <summary> /// 指定字符串转换为指定进制的数字形式 /// </summary> /// <param name="str">字符串</param> /// <param name="characters">进制格式</param> /// <param name="customCharacter">自定义进制字符串</param> /// <returns>结果</returns> public static long ToNumberLong(this string str, Characters characters = Characters.DECIMAL, string customCharacter = CHARS_PUREUPPERCHAR) { string DisplayText = characters.DisplayText(); if (characters == Characters.Custom && !customCharacter.IsNullOrEmpty()) { DisplayText = customCharacter; } long result = 0; int j = 0; foreach (var ch in new string(str.ToCharArray().Reverse().ToArray())) { if (!DisplayText.Contains(ch)) { continue; } result += DisplayText.IndexOf(ch) * ((long)Math.Pow(DisplayText.Length, j)); j++; } return(result); }