Open Barcode for C#
A NuGet package that targets .NET Standard 2.0 and .NET 8, with xUnit tests in a separate project.
Install
dotnet add package OpenBarcodeGenerate a barcode
using OpenBarcode.Linear;
var bars = new UPC("03600029145").Barcode(); // 95 modulesThe example encodes UPC-A 03600029145, which gets check digit 2 and produces 95 modules. The same input gives the same modules in every Open Barcode library.
More examples
Each example uses the same modules as the tests, so the output matches the other languages.
using OpenBarcode.Linear;
var upc = new UPC("03600029145").Barcode(); // 95 modules
var ean = new EAN("400638133393").Barcode(); // 95 modules
var code39 = new Code39("CODE39").Barcode(); // 103 modulesusing OpenBarcode.Linear;
try
{
var bad = new UPC("036000291453"); // the check digit should be 2
}
catch (ArgumentException ex)
{
Console.WriteLine(ex.Message);
}Source and tests
The source, tests and release workflow are in the C# repository on GitHub.