人民幣小寫轉大寫

2021-04-15 05:14:33 字數 1242 閱讀 4861

c# code

//

例如:(new money(200)).tostring() == "貳佰元"

namespace

skyiv.util

catch

system.console.writeline(

"大寫: "+

newmoney(m));}}

}//該類過載的 tostring() 方法返回的是大寫金額字串

class

money}//

建構函式

public

money(

decimal

money)

catch

if(money100

==long

.minvalue) overflow

=true;}

//過載 tostring() 方法,返回大寫金額字串

public

override

string

tostring()

;value

=system.math.abs(money100);

parsesection(

true

);for

(inti =

0; i

<

unit.length

&&value

>

0; i++)

if(money100

<0"

負");return

reverse();}//

解析「片段」: 「角分(2位)」或「萬以內的一段(4位)」

void

parsesection(

bool

isjiaofen)

:new

string

;isallzero

=true

;for

(inti =

0; i

<

unit.length

&&value

>

0; i++)

", unit[i], digit[d]);

isallzero

=false;}

isprezero

=(d ==0

);value

/=10;}

}//反轉字串

string

reverse()}}

人民幣小寫轉大寫

package day00 public class moneyelse result result.replaceall 零角 零 result result.replaceall 零分 零 result result.replaceall 角零 角 if result.equals 零零 ret...

人民幣小寫轉大寫

小寫金額轉成大寫。param input return public static string numtochinese string input catch exception e int len 0 if temp.indexof 1 len temp.length else len temp...

人民幣小寫轉大寫

人民幣小寫轉大寫 param string number 數值 param string int unit 幣種單位,預設 元 有的需求可能為 圓 param bool is round 是否對小數進行四捨五入 param bool is extra zero 是否對整數部分以0結尾,小數存在的數字...