1. 程式人生 > 實用技巧 >C#實現將商品金額小寫轉換成大寫

C#實現將商品金額小寫轉換成大寫

/// <summary>
        /// 將商品金額小寫轉換成大寫
        /// </summary>
        /// <param name="par">小寫金額</param>
        /// <returns>處理後的大寫金額</returns>
        public static string MoneySmallToBig(string par)
        {
            String[] Scale = { "", "", "", "", "", "", "", "", "
", "", "", "", "", "", "", "", "", "" }; String[] Base = { "", "", "", "", "", "", "", "", "", "" }; string Temp = par; object str = Temp[1]; string result = null; int index = Temp.IndexOf(".", 0, Temp.Length);//判斷是否有小數點 if
(index != -1) { Temp = Temp.Remove(Temp.IndexOf("."), 1); for (int i = Temp.Length; i > 0; i--) { int Data = Convert.ToInt16(Temp[Temp.Length - i]);//得到對應的ASCII碼值 result += Base[Data - 48]; result
+= Scale[i - 1]; } } else { for (int i = Temp.Length; i > 0; i--) { int Data = Convert.ToInt16(Temp[Temp.Length - i]); result += Base[Data - 48]; Console.WriteLine(result); result += Scale[i + 1]; Console.WriteLine(result); } } //Console.WriteLine(Base[43]); return result; }