Created
April 13, 2012 20:58
-
-
Save cbcwebdev/2380158 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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