How to format a money value from an ISOCurrencySymbol in C#

Posted by nareshbhatia on Stack Overflow See other posts from Stack Overflow or by nareshbhatia
Published on 2010-04-21T02:14:56Z Indexed on 2010/04/21 2:23 UTC
Read the original article Hit count: 408

Filed under:
|
|

I have created a Money class to save money values in different currencies. The class uses 3 letter ISO symbols to store currency types:

public class Money
{
    public decimal Amount { get; set; }
    public string Currency { get; set; }
}

Is there a way in C# to use this information, say 100.00 USD, and format it as "$100.00"? Only way I know of requires CultureInfo like this:

Amount.ToString("C", CultureInfo.CreateSpecificCulture("en-US"));

However this does not work with my Money class. Is there another solution? I am open to changing my Money class.

I have searched this site for similar questions (such as this), but couldn't find one that answers the above question.

© Stack Overflow or respective owner

Related posts about format

Related posts about money