Open Barcode for C#

A NuGet package that targets .NET Standard 2.0 and .NET 8, with xUnit tests in a separate project.

Package registryNuGet
Runtime.NET Standard 2.0 and .NET 8
LicenseApache-2.0

Install

Installbash
dotnet add package OpenBarcode

Generate a barcode

Examplecsharp
using OpenBarcode.Linear;
var bars = new UPC("03600029145").Barcode(); // 95 modules

The 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.

Three barcode typescsharp
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 modules
Wrong check digitcsharp
using 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.

Other languages