https://github.com/imaun/currency-net
Currency.NET - handles Currency and Money types for you
https://github.com/imaun/currency-net
currency finance money
Last synced: about 2 months ago
JSON representation
Currency.NET - handles Currency and Money types for you
- Host: GitHub
- URL: https://github.com/imaun/currency-net
- Owner: imaun
- License: gpl-3.0
- Created: 2024-05-09T21:10:03.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-11-23T12:36:14.000Z (6 months ago)
- Last Synced: 2025-02-05T19:50:33.166Z (3 months ago)
- Topics: currency, finance, money
- Language: C#
- Homepage:
- Size: 71.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Currency.NET
**CurrencyDotNet** is a robust .NET library for handling international currencies.
It contains all the information about the international currencies based on
[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).
You can access all of these currencies in the [`CurrencySource`]()
which is a static class. You can use it to find a specific currency by it's `curencyCode` or symbol.### Features
- **Coverage**: Includes all standard ISO-4217 Currencies in a static class
- **Easy Retrieval**: Retrieve currencies by ISO code, numeric code, or get a complete list of available currencies.
- **Immutable Objects**: Ensures currency instances are immutable, promoting thread safety and consistency.### How to use
You can install it via Nuget:
```bash
dotnet add package CurrencyDotNet
```
Or via the NuGet Package Manager:
```bash
Install-Package CurrencyDotNet
```
#### Creating a Custom Currency
Although CurrencyDotNet provides predefined currencies, you can also create custom currency instances if needed.
```csharp
// Creating a custom currency
Currency customCurrency = Currency.Create(
isoCode: "XYZ",
numericCode: "999",
englishName: "Xyzian Dollar",
symbol: "X$",
decimalCount: 2,
persianName: "دلار ایکس",
locations: new[] { "Xyzland" },
wikipediaUrl: "https://en.wikipedia.org/wiki/Xyzian_dollar",
alternativeSymbols: new[] { "XYZ$", "X-Dollar" }
);
```
#### Retrieving Currencies
CurrencyDotNet provides static methods to retrieve currencies by their ISO code or numeric code, as well as to fetch all available currencies.```csharp
// Retrieve a currency by ISO code
Currency? usd = Currency.WithCode("USD");
if (usd != null)
{
Console.WriteLine($"USD Symbol: {usd.Symbol}");
}// Retrieve a currency by numeric code
Currency? eur = Currency.WithNumericCode("978");
if (eur != null)
{
Console.WriteLine($"EUR Name: {eur.Name}");
}// Get all available currencies
var allCurrencies = Currency.GetAll();
foreach (var currency in allCurrencies.Take(5)) // Display first 5 for brevity
{
Console.WriteLine($"{currency.IsoCode} - {currency.Name} ({currency.Symbol})");
}
```Made with ❤️ by **imun**