Skip to content

Instantly share code, notes, and snippets.

@cbcwebdev
Created April 13, 2012 20:58
Show Gist options
  • Save cbcwebdev/2380158 to your computer and use it in GitHub Desktop.
Save cbcwebdev/2380158 to your computer and use it in GitHub Desktop.
public class Money
{
public readonly decimal Amount;
public readonly string CurrencyCode;
public Money(decimal amount)
: this(amount, "en-us")
{ }
public Money(decimal amount, string currencyCode)
{
Amount = amount;
CurrencyCode = currencyCode;
}
public Money Convert(string currencyCode)
{
return new Money(Amount, currencyCode);
}
public override string ToString()
{
return Amount.ToString("C", CultureInfo.CreateSpecificCulture(CurrencyCode));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment