日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > C# >内容正文

C#

c# 阿拉伯数字转成中文

發布時間:2023/12/18 C# 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c# 阿拉伯数字转成中文 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
調用方法:public string ConvertToChineseNumber(string old){Chinese ch = new Chinese();long num = Convert.ToInt64(old);string re = ch.returnResult(num);if (re.StartsWith("壹拾")){re = re.Substring(1, re.Length - 1);}return (re);}

?

完整代碼 using System; using System.Collections.Generic; using System.Text;namespace Public {class Chinese{public string returnResult(long num){string numStr = num.ToString();if (numStr.Length > 8 & numStr.Length < 16){string[] firstSplit = new string[2];firstSplit[0] = numStr.Substring(0, numStr.Length - 8);firstSplit[1] = numStr.Substring(numStr.Length - 8, 8);string result1 = getString(firstSplit[0]) + "";string result2 = getString(firstSplit[1]);return result1 + result2;}else{return getString(numStr);}}public string getString(string str){if (str.Length > 4){string[] secondSplit = new string[2];secondSplit[0] = str.Substring(0, str.Length - 4);secondSplit[1] = str.Substring(str.Length - 4, 4);string result1 = getRe(secondSplit[0]);string result2 = getRe(secondSplit[1]);if (!secondSplit[0].Equals("0000")){result1 += "";}return result1 + result2;}else{return getRe(str);}}int[] value = { 1000, 100, 10 };public string getRe(string doWith){char[] number = doWith.ToCharArray();int length = number.Length;string re = "";for (int i = 0; i < length; i++){switch (number[i]){case '0':if (re.EndsWith("")){re += "";}else{re += "";}break;case '1':re += "";break;case '2':re += "";break;case '3':re += "";break;case '4':re += "";break;case '5':re += "";break;case '6':re += "";break;case '7':re += "";break;case '8':re += "";break;case '9':re += "";break;}int index = (int)Math.Pow(10, length - i - 1);if (number[i].ToString() == "0"){index = -1;}switch (index){case 1000:re += "";break;case 100:re += "";break;case 10:re += "";break;}}if (re.EndsWith("")){re = re.Substring(0, re.Length - 1);}return re;}} }

?

?

http://files.cnblogs.com/files/louby/1279894919.rar

總結

以上是生活随笔為你收集整理的c# 阿拉伯数字转成中文的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。