MoneyHelper 1.0.1

dotnet add package MoneyHelper --version 1.0.1
                    
NuGet\Install-Package MoneyHelper -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MoneyHelper" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MoneyHelper" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="MoneyHelper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MoneyHelper --version 1.0.1
                    
#r "nuget: MoneyHelper, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MoneyHelper@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MoneyHelper&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=MoneyHelper&version=1.0.1
                    
Install as a Cake Tool

MoneyHelper

  • The nuget package enables to user to get Money model which includes integral, decimal, whole number, currency code, currency symbol, and formatted string amount by different cultural appearances of amount.
  • Money package has FormatDecimalAmountToMoney method for converting decimal to Money model.
  • It has different overloaded methods which has method parameters like amount, currencyCode, nDigit and seperatorType.

Method parametrers

amount: decimal amount value like 1034.56789
currencyCode: currency code of amount (It can sent null or empty string). The currency code determines the currency symbol of the Money class. Also, the model includes the currency code value that you send.
nDigit: It determines the length of decimal part. If you don't send or default you get whole decimal part of amount.
seperatorType: seperatorType determines Text value format. ex: 1,043.567 (DecimalSeperatorType.Dot) or 1.043,567 (DecimalSeperatorType.Comma)

Response Model

IntegralPart: Integral part of a decimal amount ex: 1034.567 --> 1034
DecimalPart: Integral part of a decimal amount. ex: 1034.567 --> 567 It depends on nDigit parameter of FormatDecimalAmountToMoney method, if you send 2 to the nDigit, you get 56.
CurrencyCode: It is created for the integrity of the money model. Also, it determines the currency symbol. If you send USD, you can get $ sign.
CurrencySymbol: The currency symbol of currency code. It is determined by currency code value.
Amount: Whole number of amount value.
Text: Formatted string value of amount. It depends on DecimalSeperatorType Enum Value.
Default value is comma seperator of integral part, comma seperator of numbers. ex: 1.034,567
Text value can be changable by dot seperator of decimal part, comma seperator of numbes. ex: 1,034.567

Demo:

using MoneyHelper;
using Newtonsoft.Json;

var amount = 1034.5678m;
var moneyModel = Money.FormatDecimalAmountToMoney(amount, "USD");
var moneyModelByCommaSeparator = Money.FormatDecimalAmountToMoney(amount, "USD", Money.DecimalSeperatorType.Dot);

var jsonData = JsonConvert.SerializeObject(moneyModel);
var jsonDataV2 = JsonConvert.SerializeObject(moneyModelByCommaSeparator);

Console.WriteLine(jsonData);
Console.WriteLine(jsonDataV2);

Result:

{
  "IntegralPart": 1034,
  "DecimalPart": 5678,
  "CurrencyCode": "USD",
  "CurrencySymbol": "$",
  "Amount": 1034.5678,
  "Text": "1.034,568"
}

{
  "IntegralPart": 1034,
  "DecimalPart": 5678,
  "CurrencyCode": "USD",
  "CurrencySymbol": "$",
  "Amount": 1034.5678,
  "Text": "1,034.568"
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 304 10/16/2023
1.0.0 165 10/15/2023