This project is read-only.

Basic usage example for the Money Class

SimpleMoney (not shown here) is even easier to use and has the same functionality except for the abitlity to work with multiple currencies.

Here is a snippet from one of the Money unit test methods:

      //Locale specific formatting
      Money money1 = new Money(2000.1234567m, CurrencyCodes.USD);
      Assert.AreEqual("$2,000.12", money1.ToString());
      //Generic 3char currency code formatting instead of symbols
      Assert.AreEqual("USD 2,000.12", money1.ToString(true));
      //Default currency (This is R in South Africa)
      Money money2 = 0.01m;
      // Operators use internal double value
      Assert.AreEqual("R 0.01", (money2 / 2).ToString());
      Money money3 = new Money(3, CurrencyCodes.EUR);
      Money money5 = new Money(6, CurrencyCodes.EUR);
      //Using implicit casting
Assert.IsTrue(money3 == 3); Assert.IsTrue(money5 - money3 == 3); Assert.IsTrue(money3 + 3d == money5); Assert.IsTrue(money5 - 3m == money3); Assert.IsTrue(money5 + 2.0 == 8); Assert.IsTrue(money5 - 2 == 4d); Assert.IsTrue(2m + money3.Amount == 5);
Much more functionality implemented. Download the source code to check it out, or have a look at the unit tests on the download page for a complete view on supported features.

Last edited Jun 14, 2012 at 12:23 PM by k33p3rpb, version 7

Comments

No comments yet.