A modern .NET library for converting and validating Roman numerals in your applications.
Install Numeri Romani using the NuGet Package Manager.
The library currently supports integers in the range from 0 to 499,999.
Use the ToRoman() extension method to easily convert an integer to its Roman numeral representation:
using LinkeEngineering.NumeriRomani;
int number = 123;
string roman = number.ToRoman();
// assigns "CXXIII"For advanced formatting, use the RomanNumeralsFormatter with String.Format(). Supported format strings are: empty, "g", "G", or "R".
using LinkeEngineering.NumeriRomani;
int number = 123;
RomanNumeralsFormatter formatter = new();
string roman = String.Format(formatter, "{0:R}", number);
// assigns "CXXIII"Use the extensions method ParseRoman() to convert a Roman numeral string to its integer value:
using LinkeEngineering.NumeriRomani;
string roman = "CXXIII";
int number1 = roman.ParseRoman()
// assigns 123Use the extension method TryParseRoman() to safely parse a Roman numeral string to its integer value:
using LinkeEngineering.NumeriRomani;
string roman = "CXXIII";
bool isSuccess = roman.TryParseRoman(out int number);
// returns true and assigns 123 to numberThis library is licensed under the MIT License, with additional terms restricting the use of the original package name for modified versions. Please refer to the license file for details.