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條碼

A Code 39 條形碼是一種流行的條形碼格式,長度可以變化。 它是最廣泛使用的條形碼型別之一。 標準Code 39 能夠編碼大寫字母(A-Z)、數字(0-9)、以及一些特殊字元(如空格、-、$、+、% 和 。)。

此外,Code 39 的 擴展模式 可以處理所有 ASCII 字元。 這種格式非常多功能,是庫存、物流和工業應用的熱門選擇。 IronBarcode 完全支援讀取 Code 39 的標準和擴展模式。在這個程式碼範例中,我們展示如何使用 IronBarcode 讀取 Code 39 條形碼並列印出結果。

讀取 Code39 條形碼的4步指南

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

程式碼解釋

我們首先導入 IronBarcode 程式庫。 然後,我們建立一個 BarcodeReaderOptions 物件。 我們將其 ExpectBarcodeTypes 屬性設置為 BarcodeEncoding.Code39 以優化讀取器,告訴它僅尋找 Code 39 條形碼。

在建立選項物件後, 我們調用 BarcodeReader.Read 方法。 我們向此方法傳遞兩個參數:條形碼圖像的路徑和我們剛配置的選項物件。 在上面的範例中,這些分別是 "code39.png" 和 options。

此方法返回 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天試用金鑰
無需信用卡或帳戶建立