开发者

Format String Numeric to Currency

开发者 https://www.devze.com 2023-04-11 20:11 出处:网络
I need to read a number in the following format to 1000 and convert currency开发者_StackOverflow中文版.

I need to read a number in the following format to 1000 and convert currency开发者_StackOverflow中文版. Note that number above "1000" realy would be 10.00. Is there any method to convert this format?


string.Format("{0:c}",your_value)

UPDATE (thanks for the comments)

string.Format("{0:c}",your_value/100);


I think you want

public String FormatValue( int valueAsCents ){
  Decimal.Divide( (decimal)valueAsCents , 100.0 ).ToString("C");
}


Icarus' answer will result in $1,000, the below is what you want.

string.Format("{0:c}",your_value/100)
0

精彩评论

暂无评论...
验证码 换一张
取 消