(C #) Value currency's uppercase conversion

xiaoxiao2021-03-06  78

I have now made the project to the numeric currency, convert it into capital, searched online, did not find the type written by C #, have to write itself, test, can meet the requirements, just the algorithm is a bit cumbersome, which The prawn is another change! Here is my code: use system; use system.collections; useing system.componentmodel; using system.windows.form; using system.data;

Summary description of Namespace Winmarket {///

/// ClassFun. /// public class classfun {private string capstr; public classfun () {// // Todo: Add constructor logic //} public string MoneyNumTocap (Decimal Num) {String Cap = "Zero叁 柒捌 柒捌 "; string numstr =" 0123456789 "; string Moneynumstr = Num.toString (); int pint = MoneynumStr.Indexof (". "); Int Numint

string Moneyint = null; string Moneydec = null; string Intstr = null; string MoneyCap = null; string Moneyintstr = null; string Moneydecstr = null; // Capstr = Pint.ToString (); if (! Pint = - 1) {string Strarr = "."; char [] charr = strarr.tochararray (); string [] MoneyNumarr = MoneyNumStr.Split (Chararr); Moneyint = MoneyNumarr [0] .tostring (); MoneyDec = MoneyNumarr [1] .tostring () ; IF (MoneyDec.Length <2) {MoneyDec = MoneyDec "0";

} Else {Moneyint = MoneyNumStr; MoneyDec = "00";

IF (MoneyinT.Length> 16) {MessageBox.show ("Value Superior");} else {// --- Process Integer Part -------- for (INT J = 1; J <= Moneyint .Length; j ) {MoneyintStr = Moneyint.substring (j-1, 1); for (int i = 0; i <= 9; i ) {INTSTR = Numstr.Substring (i, 1); Moneycap = Cap.substring (I, 1); if (MoneyintStr == INTSTR) {Switch (INTST) {CASE "0": Capstr = Capstr Moneycap; Break; Case "1": Capstr = Capstr Moneycap; Break; Case "2": Capstr = Capstr MoneyCap; Break; Case "3": Capstr = Capstr MoneyCap; Break; Case "4": Capstr = CAPSTR MONEYCAP; BREAK; CASE "5": Capstr = Capstr Moneycap; Break; Case "6 ": Capstr = Capstr MoneyCap; Break; Case" 7 ": Capstr = Capstr Moneycap; Break; Case" 8 ": Capstr = CAPSTR MONEYCAP; BREAK; CASE" 9 ": Capstr = Capstr Moneycap; Break;}}} Numint = Moneyint.LENGTH-J 1; Switch (Numint) {Case 16: Capstr = Capstr "仟"; Break; Case 15: Capstr = Capstr ""; Break; Case 14: Capstr = Capstr "Pick up"; Break; Case 13: Capstr = Capstr "Wan"; Break; Case 12: Capstr = Capstr "仟"; Break; Case 11: Capstr = Capstr ""; Break;

CASE 10: CAPSTR = Capstr "Pick"; Break; Case 9: Capstr = Capstr "Break; Case 8: Capstr = Capstr " 仟 "; Break; Case 7: Capstr = Capstr " "; Break; Case 6 : Capstr = Capstr "Pick"; Break; Case 5: Capstr = CAPSTR "10; Break; Case 4: Capstr = Capstr " 仟 "; Break; Case 3: Capstr = Capstr " "; Break; Case 2: Capstr = Capstr "Pick"; Break; Case 1: Capstr = Capstr "Yuan"; Break;}} // ------ Processing fractional part ----- for (int J = 1; j <= 2; J ) {MoneyDecstr = MoneyDec.Substring (J-1, 1);

For (int i = 0; i <= 9; i ) {INTSTR = NumStr.SUBSTRING (i, 1); MoneyCap = Cap.Substring (i, 1); if (MoneyDecstr == INTSTR) {Switch (INTSTR) { CASE "0": Capstr = Capstr Moneycap; Break; Case "1": Capstr = Capstr Moneycap; Break; Case "2": Capstr = Capstr Moneycap; Break; Case "3": Capstr = Capstr Moneycap; Break; Case "4": Capstr = Capstr Moneycap; Break; Case "5": Capstr = CAPSTR MONEYCAP; BREAK; CASE "6": Capstr = CAPSTR MONEYCAP; BREAK; CASE "7": Capstr = CAPSTR MoneyCap; Break; Case "8": Capstr = Capstr Moneycap; Break; Case "9": Capstr = Capstr Moneycap; Break;}}} Switch (j) {CASE 1: Capstr = Capstr "Corner"; Break; Case 2: Capstr = Capstr "Division"; Break;

}

}

}

Return capstr;}

}

转载请注明原文地址:https://www.9cbs.com/read-94871.html

New Post(0)