Git Product home page Git Product logo

money's Introduction

DEPRICATED

Code has moved to https://github.com/busterwood/Goodies

Build status Nuget

Money

The Money struct prevents you accidently adding numbers together that repesents different currencies.

The Money constructor requires a decimal amount and an ISO currency code string.

Basic operators include:

  • - for negation
  • * for multiplication
  • / for division
  • == for equality
  • != for inequality

If different currencies are passed to any of the following operators then an InvalidOperationException will be thrown:

  • + for addition
  • - for substraction
  • > for greater than comparision
  • < for less than comparison
  • >= for greater than or equal to comparision
  • <= for less than or equal to comparison

There also extension methods add to decimal for conversion to some common currencies, i.e. 1m.GBP(), 2m.USD() and 3m.EUR()

MoneyBag

The MoneyBag class is a collection of money in one or more currencies, and has the following methods:

  • Add(Money m)
  • Substract(Money m)
  • Contains(string currency)
  • Money Remove(string currency)
  • GetEnumerator to enumerate the totals of each currency

MoneyBag also has an Money this[string currency] getter property that will return the amount of a currency in the bag, or zero if the bag does not contain the currency.

Currencies

The static Currencies class has a int? DecimalPlaces(string currency) method used to determine the decimal places used for all known ISO currency codes, including Bitcoin etc.

Both Money and MoneyBag use Currencies to correctly format money amounts.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.