91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

C#轉換人民幣大小金額

發布時間:2020-06-20 19:53:00 來源:網絡 閱讀:487 作者:linzheng 欄目:開發技術

 

  1. /// <summary>   
  2.         /// 轉換人民幣大小金額   
  3.         /// </summary>   
  4.         /// <param name="num">金額</param>   
  5.         /// <returns>返回大寫形式</returns>   
  6.         public static string GetChineseMoney(decimal num)  
  7.         {  
  8.             string str1 = "零壹貳叁肆伍陸柒捌玖";            //0-9所對應的漢字   
  9.             string str2 = "萬仟佰拾億仟佰拾萬仟佰拾元角分"//數字位所對應的漢字   
  10.             string str3 = "";    //從原num值中取出的值   
  11.             string str4 = "";    //數字的字符串形式   
  12.             string str5 = "";  //人民幣大寫金額形式   
  13.             int i;    //循環變量   
  14.             int j;    //num的值乘以100的字符串長度   
  15.             string ch2 = "";    //數字的漢語讀法   
  16.             string ch3 = "";    //數字位的漢字讀法   
  17.             int nzero = 0;  //用來計算連續的零值是幾個   
  18.             int temp;            //從原num值中取出的值   
  19.  
  20.             if (DbUtils.Language.ToLower() == "en"return "";  
  21.             num = Math.Round(Math.Abs(num), 2);    //將num取絕對值并四舍五入取2位小數   
  22.             str4 = ((long)(num * 100)).ToString();        //將num乘100并轉換成字符串形式   
  23.             j = str4.Length;      //找出最高位   
  24.             if (j > 15) { return "溢出"; }  
  25.             str2 = str2.Substring(15 - j);   //取出對應位數的str2的值。如:200.55,j為5所以str2=佰拾元角分   
  26.  
  27.             //循環取出每一位需要轉換的值   
  28.             for (i = 0; i < j; i++)  
  29.             {  
  30.                 str3 = str4.Substring(i, 1);          //取出需轉換的某一位的值   
  31.                 temp = Convert.ToInt32(str3);      //轉換為數字   
  32.                 if (i != (j - 3) && i != (j - 7) && i != (j - 11) && i != (j - 15))  
  33.                 {  
  34.                     //當所取位數不為元、萬、億、萬億上的數字時   
  35.                     if (str3 == "0")  
  36.                     {  
  37.                         ch2 = "";  
  38.                         ch3 = "";  
  39.                         nzero = nzero + 1;  
  40.                     }  
  41.                     else 
  42.                     {  
  43.                         if (str3 != "0" && nzero != 0)  
  44.                         {  
  45.                             ch2 = "零" + str1.Substring(temp * 1, 1);  
  46.                             ch3 = str2.Substring(i, 1);  
  47.                             nzero = 0;  
  48.                         }  
  49.                         else 
  50.                         {  
  51.                             ch2 = str1.Substring(temp * 1, 1);  
  52.                             ch3 = str2.Substring(i, 1);  
  53.                             nzero = 0;  
  54.                         }  
  55.                     }  
  56.                 }  
  57.                 else 
  58.                 {  
  59.                     //該位是萬億,億,萬,元位等關鍵位   
  60.                     if (str3 != "0" && nzero != 0)  
  61.                     {  
  62.                         ch2 = "零" + str1.Substring(temp * 1, 1);  
  63.                         ch3 = str2.Substring(i, 1);  
  64.                         nzero = 0;  
  65.                     }  
  66.                     else 
  67.                     {  
  68.                         if (str3 != "0" && nzero == 0)  
  69.                         {  
  70.                             ch2 = str1.Substring(temp * 1, 1);  
  71.                             ch3 = str2.Substring(i, 1);  
  72.                             nzero = 0;  
  73.                         }  
  74.                         else 
  75.                         {  
  76.                             if (str3 == "0" && nzero >= 3)  
  77.                             {  
  78.                                 ch2 = "";  
  79.                                 ch3 = "";  
  80.                                 nzero = nzero + 1;  
  81.                             }  
  82.                             else 
  83.                             {  
  84.                                 if (j >= 11)  
  85.                                 {  
  86.                                     ch2 = "";  
  87.                                     nzero = nzero + 1;  
  88.                                 }  
  89.                                 else 
  90.                                 {  
  91.                                     ch2 = "";  
  92.                                     ch3 = str2.Substring(i, 1);  
  93.                                     nzero = nzero + 1;  
  94.                                 }  
  95.                             }  
  96.                         }  
  97.                     }  
  98.                 }  
  99.                 if (i == (j - 11) || i == (j - 3))  
  100.                 {  
  101.                     //如果該位是億位或元位,則必須寫上   
  102.                     ch3 = str2.Substring(i, 1);  
  103.                 }  
  104.                 str5 = str5 + ch2 + ch3;  
  105.  
  106.                 if (i == j - 1 && str3 == "0")  
  107.                 {  
  108.                     //最后一位(分)為0時,加上“整”   
  109.                     str5 = str5 + '整';  
  110.                 }  
  111.             }  
  112.             if (num == 0)  
  113.             {  
  114.                 str5 = "零元整";  
  115.             }  
  116.             return str5;  
  117.         } 

 

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

永昌县| 宁河县| 封开县| 五家渠市| 周宁县| 深圳市| 新宁县| 文水县| 阿克苏市| 石首市| 康平县| 丹寨县| 呼玛县| 潞西市| 河北省| 汉寿县| 和平县| 称多县| 定南县| 邹平县| 南溪县| 五台县| 张家口市| 洛宁县| 孟津县| 茂名市| 苍山县| 颍上县| 鹰潭市| 阜宁县| 张北县| 香港| 阿合奇县| 米脂县| 九龙县| 聊城市| 淮南市| 镇坪县| 南平市| 连山| 额济纳旗|