bnspellnum

C# / .NET

BnSpellNum on NuGet. .NET Standard 2.0 and .NET 8, zero dependencies.

Install

Any .NET implementation that supports .NET Standard 2.0 (.NET Framework 4.6.1+, .NET Core 2.0+, .NET 5+). nuget.org/packages/BnSpellNum

dotnet add package BnSpellNum

Quick start

using Ediphas.BnSpellNum;

BnSpell.Words(1250000);                        // বারো লাখ পঞ্চাশ হাজার
BnSpell.Words(200, Style.Formal);              // দুইশত
BnSpell.Words(1.50m);                          // এক দশমিক পাঁচ শূন্য
BnSpell.Words(BigInteger.Pow(10, 21));         // এক কোটি কোটি কোটি
BnSpell.Currency(1250.50m, cheque: true);      // এক হাজার দুইশো পঞ্চাশ টাকা পঞ্চাশ পয়সা মাত্র
BnSpell.Ordinal(2, shortForm: true);           // ২য়
BnSpell.Year(1971);                            // উনিশশো একাত্তর
BnSpell.Date(16, 12, 1971);                    // ষোলোই ডিসেম্বর উনিশশো একাত্তর
BnSpell.Date(28, 11, style: DateStyle.Short);  // ২৮শে নভেম্বর
BnSpell.ToBnDigits("2026");                    // ২০২৬

API

SignatureReturns
Words(long | BigInteger | decimal | string n, Style style = Colloquial, Style negativeStyle = Formal)string
Ordinal(long | string n, bool shortForm = false)string
Year(long | string n, YearMode mode = Auto)string
Date(int day, int month, int? year = null, DateStyle style = Spoken) (also string overload)string
Currency(decimal | long | string amount, bool cheque = false, Style style = Colloquial)string
ToBnDigits(string | long), ToEnDigits(string)string
BnSpell.Version, BnSpell.SpecVersionstring

Input types

The static class is BnSpell in namespace Ediphas.BnSpellNum, with enums Style, YearMode and DateStyle. The decimal overloads keep scale, so 1.50m and 1.5m read differently. There are no double overloads on purpose.

Errors

try
{
    BnSpell.Date(30, 2);
}
catch (OutOfRangeException e)   // derives from BnSpellNumException, an ArgumentException
{
    Console.WriteLine($"{e.Code}: {e.Message}");   // OutOfRange: ...
}

More