IRONSOFTWAREHOME
读取 Code 39 条形码
using IronBarCode;
using System;

// Set the option to read single code 39 barcode
BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    ExpectBarcodeTypes = BarcodeEncoding.Code39
};

// Read barcode
var results = BarcodeReader.Read("code39.png", options);

foreach (var result in results)
{
    Console.WriteLine(result.ToString());
}
Imports IronBarCode
Imports System

' Set the option to read single code 39 barcode
Dim options As New BarcodeReaderOptions() With {
    .ExpectBarcodeTypes = BarcodeEncoding.Code39
}

' Read barcode
Dim results = BarcodeReader.Read("code39.png", options)

For Each result In results
    Console.WriteLine(result.ToString())
Next
NuGet Download
PM > Install-Package BarCode
读取 Code 39 条形码

读取 Code 39 条形码

Code 39条形码是一种流行的条形码格式,其长度可以变化。 它是应用最广泛的条形码类型之一。 标准代码 39能够编码大写字母 (AZ)、数字 (0-9) 和一些特殊字符(例如空格、-、$、+、% 和 .)。

此外,Code 39 的扩展模式可以处理所有 ASCII 字符。 这种格式用途广泛,是库存管理、物流和工业应用的热门选择。 IronBarcode 完全支持读取 Code 39 的标准模式和扩展模式。在本代码示例中,我们将演示如何使用 IronBarcode 读取 Code 39 条形码并打印结果。

解读 Code39 条形码的四步指南

  • BarcodeReaderOptions options = new BarcodeReaderOptions();
  • ExpectBarcodeTypes = BarcodeEncoding.Code39;
  • var results = BarcodeReader.Read("code39.png", options);
  • Console.WriteLine(result.ToString());

代码解释

我们首先导入 IronBarcode 库。 然后,创建一个BarcodeReaderOptions对象。 我们将其BarcodeEncoding.Code39来优化读取器,告知它只查找Code 39条码。

创建选项对象后,我们调用BarcodeReader.Read方法。 我们向此方法传递两个参数:条形码图像的路径和我们刚刚配置的选项对象。 在上面的示例中,它们分别是"code39.png"和选项。

此方法返回一组BarcodeResult对象。 最后,可以从结果集合中访问一个结果,并使用Console.WriteLine(result.ToString())将其解码的字符串值打印到控制台。

了解如何使用 C# 和 IronBarcode 轻松读取 Code 39 条形码!
在 GitHub 上查看

准备开始了吗?

Nuget Downloads 2,422,100版本:2026.9刚刚发布

Key in blue circle

立即获取免费的 30 天试用版密钥

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥
无需信用卡或创建账户