C#'taki Barkod İşlemleri İçin Null Kontrolü Nasıl Yapılır
IronBarcode, C# içinde BarcodeReader.Read aracılığıyla tarama sonuçlarını BarcodeResults koleksiyonu olarak döndürür. Bu yöntem, giriş görüntüsü tanınmazsa null döndürür veya barkodlar tespit edilmezse boş bir koleksiyon döndürür. BarcodeWriter.CreateBarcode, giriş null, boş veya geçersiz formatta olduğunda bir istisna fırlatır.
Kamera beslemeleri, belge yüklemeleri ve depo tarayıcıları gibi gerçek dünya tarama kaynakları her zaman okunabilir bir barkod sağlamayabilir. Sonuç özelliklerine erişmek veya koleksiyonu null veya boş değerler için kontrol etmeden yinelemek, çalışma zamanında NullReferenceException neden olabilir. Yazma API'sine geçersiz dizeler geçirmek bir ArgumentException ile sonuçlanabilir. Okuma ve yazma işlemlerinde önleyici önlemler almak, bu istisnaların üretimde önlenmesine yardımcı olur.
Bu nasıl yapılır klavuzu, IronBarcode okuma ve yazma işlemlerinde null ve boş sonuçlarla başa çıkmayı, koruyucu ifade, güven filtrelemesi ve yeniden kullanılabilir bir doğrulayıcı deseni kullanarak açıklar.
Hızlı Başlangıç: Barkod İşlemlerinde Null Sonuçları Ele Alma
Sonuç özelliklerine erişmeden önce BarcodeResults koleksiyonunu güvenli bir şekilde kontrol etmek için IronBarcode'un koruma desenini kullanın. Hızlı bir şekilde başlamak için bu minimal okuma ve kontrol ile hemen başlayın:
-
1IronBarcode ile NuGet Package Manager'u yükleyin
-
2Bu kod parçacığını kopyalayın ve çalıştırın.
using IronBarCode; using System; using System.Linq; BarcodeResults results = BarcodeReader.Read("label.png"); // Guard: null or empty if (results is null || results.Count == 0) { Console.WriteLine("No barcodes detected."); return; } Console.WriteLine(results.First().Value);Imports IronBarCode Imports System Imports System.Linq Dim results As BarcodeResults = BarcodeReader.Read("label.png") ' Guard: null or empty If results Is Nothing OrElse results.Count = 0 Then Console.WriteLine("No barcodes detected.") Return End If Console.WriteLine(results.First().Value)Imports IronBarCode Imports System Imports System.Linq Dim results As BarcodeResults = BarcodeReader.Read("label.png") ' Guard: null or empty If results Is Nothing OrElse results.Count = 0 Then Console.WriteLine("No barcodes detected.") Return End If Console.WriteLine(results.First().Value) -
3Canlı ortamınızda test için dağıtım yapın
Projenizde IronBarcode'yi bugün ücretsiz deneme sürümü ile kullanmaya başlayın
IronBarcode ile Barkod İşlemleri İçin Null Kontrolü Nasıl Ele Alınır
- IronBarcode kütüphanesini NuGet'ten indirin
BarcodeReader.Readçağrın veBarcodeResultsdöndürülen değeri yakalayın- Herhangi bir sonuca erişmeden önce null olup olmadığını kontrol edin
- Aşağı akışı kullanmadan önce bireysel
BarcodeResultözelliklerini doğrulayın - Düşük kaliteli okumaları tarama seviyesinde filtrelemek için
BarcodeReaderOptionsüzerindeConfidenceThresholdayarlayın
Null ve Boş Barkod Sonuçları Nasıl Ele Alınır?
İki başarısızlık modu vardır: Giriş geçerli bir resim değilse BarcodeResults null olur ve resim hiçbir barkod içermiyorsa boştur. First, Value veya her iki koşulu doğrulamadan yineleme çalışma zamanında bir istisnaya neden olacaktır.
İşleme döngüsüne girmeden önce her iki durumu da kontrol edin:
Giriş
Code128 barkod gönderim etiketi (başarı yolu) ve içinde barkod bulunmayan boş bir resim (başarısızlık yolu).

shipping-label.png (başarı yolu)

blank-image.png (başarısızlık yolu, barkod yok)
using IronBarCode;
// BarcodeReader.Read() returns a BarcodeResults collection, not a single result
BarcodeResults results = BarcodeReader.Read("shipping-label.png");
// Null check: image was not recognized as a valid image source
// Empty check: image was valid but contained no detectable barcodes
if (results is null || results.Count == 0)
{
// Log, return a default, or throw a domain-specific exception
Console.WriteLine("No barcodes found in the input image.");
return;
}
// Collection is safe to iterate; each BarcodeResult holds one decoded barcode
foreach (BarcodeResult result in results)
{
// Guard individual result properties; partial scans or severely
// damaged barcodes can produce results where .Value is empty or whitespace
if (string.IsNullOrWhiteSpace(result.Value))
{
Console.WriteLine($"Empty value detected for {result.BarcodeType}");
continue;
}
// BarcodeType identifies the symbology (Code128, QRCode, EAN8, etc.)
Console.WriteLine($"Type: {result.BarcodeType}, Value: {result.Value}");
}using IronBarCode;
// BarcodeReader.Read() returns a BarcodeResults collection, not a single result
BarcodeResults results = BarcodeReader.Read("shipping-label.png");
// Null check: image was not recognized as a valid image source
// Empty check: image was valid but contained no detectable barcodes
if (results is null || results.Count == 0)
{
// Log, return a default, or throw a domain-specific exception
Console.WriteLine("No barcodes found in the input image.");
return;
}
// Collection is safe to iterate; each BarcodeResult holds one decoded barcode
foreach (BarcodeResult result in results)
{
// Guard individual result properties; partial scans or severely
// damaged barcodes can produce results where .Value is empty or whitespace
if (string.IsNullOrWhiteSpace(result.Value))
{
Console.WriteLine($"Empty value detected for {result.BarcodeType}");
continue;
}
// BarcodeType identifies the symbology (Code128, QRCode, EAN8, etc.)
Console.WriteLine($"Type: {result.BarcodeType}, Value: {result.Value}");
}Imports IronBarCode
' BarcodeReader.Read() returns a BarcodeResults collection, not a single result
Dim results As BarcodeResults = BarcodeReader.Read("shipping-label.png")
' Null check: image was not recognized as a valid image source
' Empty check: image was valid but contained no detectable barcodes
If results Is Nothing OrElse results.Count = 0 Then
' Log, return a default, or throw a domain-specific exception
Console.WriteLine("No barcodes found in the input image.")
Return
End If
' Collection is safe to iterate; each BarcodeResult holds one decoded barcode
For Each result As BarcodeResult In results
' Guard individual result properties; partial scans or severely
' damaged barcodes can produce results where .Value is empty or whitespace
If String.IsNullOrWhiteSpace(result.Value) Then
Console.WriteLine($"Empty value detected for {result.BarcodeType}")
Continue For
End If
' BarcodeType identifies the symbology (Code128, QRCode, EAN8, etc.)
Console.WriteLine($"Type: {result.BarcodeType}, Value: {result.Value}")
NextImports IronBarCode
' BarcodeReader.Read() returns a BarcodeResults collection, not a single result
Dim results As BarcodeResults = BarcodeReader.Read("shipping-label.png")
' Null check: image was not recognized as a valid image source
' Empty check: image was valid but contained no detectable barcodes
If results Is Nothing OrElse results.Count = 0 Then
' Log, return a default, or throw a domain-specific exception
Console.WriteLine("No barcodes found in the input image.")
Return
End If
' Collection is safe to iterate; each BarcodeResult holds one decoded barcode
For Each result As BarcodeResult In results
' Guard individual result properties; partial scans or severely
' damaged barcodes can produce results where .Value is empty or whitespace
If String.IsNullOrWhiteSpace(result.Value) Then
Console.WriteLine($"Empty value detected for {result.BarcodeType}")
Continue For
End If
' BarcodeType identifies the symbology (Code128, QRCode, EAN8, etc.)
Console.WriteLine($"Type: {result.BarcodeType}, Value: {result.Value}")
NextHer BarcodeResult, hem çözümlenmiş barkod içeriğini döndüren Value ve Text dize özelliklerini sağlar. Ciddi şekilde hasar görmüş barkodlar veya kısmi taramalar boş veya boşluk değerleri üretebilir. Boş değerlerin aşağı akış sistemlerine ulaşmasını önlemek için her sonuç üzerinde string.IsNullOrWhiteSpace kullanın.
BarcodeReaderOptions ayrıca, düşük kaliteli okumaların sonuç koleksiyonuna ulaşmadan önce düşmesini sağlayan bir ConfidenceThreshold özelliğine sahiptir (0,0'dan 1,0'e kadar):
using IronBarCode;
// ConfidenceThreshold filters low-quality reads before they enter the
// BarcodeResults collection. Reads below the threshold are discarded
// during scanning, not after, so no post-filtering of the collection is needed.
var options = new BarcodeReaderOptions
{
ConfidenceThreshold = 0.7 // range 0.0 to 1.0; lower values accept weaker signals
};
BarcodeResults results = BarcodeReader.Read("shipping-label.png", options);
// Still check for null and empty even with a threshold applied;
// an image with no barcodes returns an empty collection, not null
if (results is null || results.Count == 0)
{
Console.WriteLine("No barcodes met the confidence threshold.");
return;
}
foreach (var result in results)
Console.WriteLine($"Type: {result.BarcodeType}, Value: {result.Value}");using IronBarCode;
// ConfidenceThreshold filters low-quality reads before they enter the
// BarcodeResults collection. Reads below the threshold are discarded
// during scanning, not after, so no post-filtering of the collection is needed.
var options = new BarcodeReaderOptions
{
ConfidenceThreshold = 0.7 // range 0.0 to 1.0; lower values accept weaker signals
};
BarcodeResults results = BarcodeReader.Read("shipping-label.png", options);
// Still check for null and empty even with a threshold applied;
// an image with no barcodes returns an empty collection, not null
if (results is null || results.Count == 0)
{
Console.WriteLine("No barcodes met the confidence threshold.");
return;
}
foreach (var result in results)
Console.WriteLine($"Type: {result.BarcodeType}, Value: {result.Value}");Imports IronBarCode
' ConfidenceThreshold filters low-quality reads before they enter the
' BarcodeResults collection. Reads below the threshold are discarded
' during scanning, not after, so no post-filtering of the collection is needed.
Dim options As New BarcodeReaderOptions With {
.ConfidenceThreshold = 0.7 ' range 0.0 to 1.0; lower values accept weaker signals
}
Dim results As BarcodeResults = BarcodeReader.Read("shipping-label.png", options)
' Still check for null and empty even with a threshold applied;
' an image with no barcodes returns an empty collection, not null
If results Is Nothing OrElse results.Count = 0 Then
Console.WriteLine("No barcodes met the confidence threshold.")
Return
End If
For Each result In results
Console.WriteLine($"Type: {result.BarcodeType}, Value: {result.Value}")
NextImports IronBarCode
' ConfidenceThreshold filters low-quality reads before they enter the
' BarcodeResults collection. Reads below the threshold are discarded
' during scanning, not after, so no post-filtering of the collection is needed.
Dim options As New BarcodeReaderOptions With {
.ConfidenceThreshold = 0.7 ' range 0.0 to 1.0; lower values accept weaker signals
}
Dim results As BarcodeResults = BarcodeReader.Read("shipping-label.png", options)
' Still check for null and empty even with a threshold applied;
' an image with no barcodes returns an empty collection, not null
If results Is Nothing OrElse results.Count = 0 Then
Console.WriteLine("No barcodes met the confidence threshold.")
Return
End If
For Each result In results
Console.WriteLine($"Type: {result.BarcodeType}, Value: {result.Value}")
NextBarkod Yazma İşlemlerine Null-Güvenli Desenler Nasıl Uygulanır?
BarcodeWriter.CreateBarcode bir dize değeri ve bir BarcodeWriterEncoding veya BarcodeEncoding enum alır. Null veya boş bir dize geçirmek hemen bir hata fırlatır. Format kısıtlamaları da geçerlidir: EAN-8 7 ila 8 sayısal basamak kabul eder, UPC-A 11 ila 12 arası kabul eder ve Code 128 bir karakter sınırına sahiptir. Çağrıdan önce girdiyi doğrulamak, bu hataların kodlama adımında oluşmasını engeller:
using IronBarCode;
// Input may arrive from user input, a database, or an API response
string inputValue = GetValueFromUserOrDatabase(); // Could be null
// Guard: null, empty, or whitespace input cannot produce a valid barcode
if (string.IsNullOrWhiteSpace(inputValue))
{
Console.WriteLine("Cannot generate barcode: input value is null or empty.");
return;
}
// Guard: format-specific constraints must be satisfied before encoding
// EAN-8 accepts exactly 7 or 8 numeric digits (the 8th is the check digit)
BarcodeWriterEncoding encoding = BarcodeWriterEncoding.EAN8;
if (encoding == BarcodeWriterEncoding.EAN8 && !System.Text.RegularExpressions.Regex.IsMatch(inputValue, @"^\d{7,8}$"))
{
Console.WriteLine("EAN-8 requires exactly 7 or 8 numeric digits.");
return;
}
// Input is validated; CreateBarcode will not throw for null or format mismatch
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(inputValue, encoding);
barcode.SaveAsPng("output-barcode.png");using IronBarCode;
// Input may arrive from user input, a database, or an API response
string inputValue = GetValueFromUserOrDatabase(); // Could be null
// Guard: null, empty, or whitespace input cannot produce a valid barcode
if (string.IsNullOrWhiteSpace(inputValue))
{
Console.WriteLine("Cannot generate barcode: input value is null or empty.");
return;
}
// Guard: format-specific constraints must be satisfied before encoding
// EAN-8 accepts exactly 7 or 8 numeric digits (the 8th is the check digit)
BarcodeWriterEncoding encoding = BarcodeWriterEncoding.EAN8;
if (encoding == BarcodeWriterEncoding.EAN8 && !System.Text.RegularExpressions.Regex.IsMatch(inputValue, @"^\d{7,8}$"))
{
Console.WriteLine("EAN-8 requires exactly 7 or 8 numeric digits.");
return;
}
// Input is validated; CreateBarcode will not throw for null or format mismatch
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(inputValue, encoding);
barcode.SaveAsPng("output-barcode.png");Imports IronBarCode
' Input may arrive from user input, a database, or an API response
Dim inputValue As String = GetValueFromUserOrDatabase() ' Could be Nothing
' Guard: null, empty, or whitespace input cannot produce a valid barcode
If String.IsNullOrWhiteSpace(inputValue) Then
Console.WriteLine("Cannot generate barcode: input value is null or empty.")
Return
End If
' Guard: format-specific constraints must be satisfied before encoding
' EAN-8 accepts exactly 7 or 8 numeric digits (the 8th is the check digit)
Dim encoding As BarcodeWriterEncoding = BarcodeWriterEncoding.EAN8
If encoding = BarcodeWriterEncoding.EAN8 AndAlso Not System.Text.RegularExpressions.Regex.IsMatch(inputValue, "^\d{7,8}$") Then
Console.WriteLine("EAN-8 requires exactly 7 or 8 numeric digits.")
Return
End If
' Input is validated; CreateBarcode will not throw for null or format mismatch
Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(inputValue, encoding)
barcode.SaveAsPng("output-barcode.png")Imports IronBarCode
' Input may arrive from user input, a database, or an API response
Dim inputValue As String = GetValueFromUserOrDatabase() ' Could be Nothing
' Guard: null, empty, or whitespace input cannot produce a valid barcode
If String.IsNullOrWhiteSpace(inputValue) Then
Console.WriteLine("Cannot generate barcode: input value is null or empty.")
Return
End If
' Guard: format-specific constraints must be satisfied before encoding
' EAN-8 accepts exactly 7 or 8 numeric digits (the 8th is the check digit)
Dim encoding As BarcodeWriterEncoding = BarcodeWriterEncoding.EAN8
If encoding = BarcodeWriterEncoding.EAN8 AndAlso Not System.Text.RegularExpressions.Regex.IsMatch(inputValue, "^\d{7,8}$") Then
Console.WriteLine("EAN-8 requires exactly 7 or 8 numeric digits.")
Return
End If
' Input is validated; CreateBarcode will not throw for null or format mismatch
Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(inputValue, encoding)
barcode.SaveAsPng("output-barcode.png")Çıktı
Geçerli bir 7 basamaklı giriş (1234567) taranabilir bir EAN-8 barkodu üretir. Null, boş veya sayısal olmayan girdiler koruyucu deyimler tarafından yakalanır ve hiçbir zaman kodlama adımına ulaşmaz.

Yazma API'si de kendi dahili doğrulamalarını yapar: kontrol toplamlarını kontrol eder, uzunluk kısıtlamalarını onaylar ve seçilen kodlama için geçersiz karakterleri reddeder. Yukarıdaki koruma deyimleri, sorunları daha erken yakalar ve çağrıcıya hata mesajı üzerinde kontrol ve toparlanma yolu sağlar. Desteklenen kodlamaların tam listesi ve kısıtlamaları için, barkod oluşturma nasıl yapılır ve veriden barkod oluşturma kılavuzuna bakın.
Aşağı Akış İşlemeden Önce Sonuçlar Nasıl Doğrulanır?
Barkod verileri başka bir sisteme (bir veritabanı yazması, bir API çağrısı, bir etiket yazıcı) aktarıldığında, sonuç sayısını, değer bütünlüğünü ve tür kontrollerini tek bir yeniden kullanılabilir metoda konsolide etmek yardımcı olur:
Giriş
Doğrulayıcı için okuma hedefi olarak kullanılan bir Code128 barkod depo taraması.

using IronBarCode;
using System.Collections.Generic;
using System.Linq;
// Reusable validation helper — consolidates null, empty, value, and
// expected-format checks into a single method. Returns an empty list
// (never null) so callers do not need to null-check the return value.
public static class BarcodeValidator
{
public static List<BarcodeResult> GetValidResults(
string imagePath,
BarcodeEncoding? expectedType = null,
double confidenceThreshold = 0.7)
{
// Apply confidence threshold at scan level via BarcodeReaderOptions
var options = new BarcodeReaderOptions
{
ConfidenceThreshold = confidenceThreshold
};
BarcodeResults results = BarcodeReader.Read(imagePath, options);
// Return empty list instead of null so callers never need to null-check the return value
if (results is null || results.Count == 0)
return new List<BarcodeResult>();
return results
.Where(r => !string.IsNullOrWhiteSpace(r.Value)) // skip results with empty decoded data
.Where(r => expectedType == null || r.BarcodeType == expectedType) // null accepts any symbology
.ToList();
}
}
// Usage: pass the image path and the symbology you expect
var validated = BarcodeValidator.GetValidResults(
"warehouse-scan.png",
expectedType: BarcodeEncoding.Code128,
confidenceThreshold: 0.7);
if (validated.Count == 0)
{
// No valid results; log the failure and skip downstream processing
return;
}
// All results have passed null, empty, type, and confidence checks
foreach (var barcode in validated)
{
SendToInventorySystem(barcode.Value, barcode.BarcodeType.ToString()); // placeholder for your downstream call
}using IronBarCode;
using System.Collections.Generic;
using System.Linq;
// Reusable validation helper — consolidates null, empty, value, and
// expected-format checks into a single method. Returns an empty list
// (never null) so callers do not need to null-check the return value.
public static class BarcodeValidator
{
public static List<BarcodeResult> GetValidResults(
string imagePath,
BarcodeEncoding? expectedType = null,
double confidenceThreshold = 0.7)
{
// Apply confidence threshold at scan level via BarcodeReaderOptions
var options = new BarcodeReaderOptions
{
ConfidenceThreshold = confidenceThreshold
};
BarcodeResults results = BarcodeReader.Read(imagePath, options);
// Return empty list instead of null so callers never need to null-check the return value
if (results is null || results.Count == 0)
return new List<BarcodeResult>();
return results
.Where(r => !string.IsNullOrWhiteSpace(r.Value)) // skip results with empty decoded data
.Where(r => expectedType == null || r.BarcodeType == expectedType) // null accepts any symbology
.ToList();
}
}
// Usage: pass the image path and the symbology you expect
var validated = BarcodeValidator.GetValidResults(
"warehouse-scan.png",
expectedType: BarcodeEncoding.Code128,
confidenceThreshold: 0.7);
if (validated.Count == 0)
{
// No valid results; log the failure and skip downstream processing
return;
}
// All results have passed null, empty, type, and confidence checks
foreach (var barcode in validated)
{
SendToInventorySystem(barcode.Value, barcode.BarcodeType.ToString()); // placeholder for your downstream call
}Imports IronBarCode
Imports System.Collections.Generic
Imports System.Linq
' Reusable validation helper — consolidates null, empty, value, and
' expected-format checks into a single method. Returns an empty list
' (never null) so callers do not need to null-check the return value.
Public Module BarcodeValidator
Public Function GetValidResults(
imagePath As String,
Optional expectedType As BarcodeEncoding? = Nothing,
Optional confidenceThreshold As Double = 0.7) As List(Of BarcodeResult)
' Apply confidence threshold at scan level via BarcodeReaderOptions
Dim options As New BarcodeReaderOptions With {
.ConfidenceThreshold = confidenceThreshold
}
Dim results As BarcodeResults = BarcodeReader.Read(imagePath, options)
' Return empty list instead of null so callers never need to null-check the return value
If results Is Nothing OrElse results.Count = 0 Then
Return New List(Of BarcodeResult)()
End If
Return results _
.Where(Function(r) Not String.IsNullOrWhiteSpace(r.Value)) _ ' skip results with empty decoded data
.Where(Function(r) expectedType Is Nothing OrElse r.BarcodeType = expectedType) _ ' null accepts any symbology
.ToList()
End Function
End Module
' Usage: pass the image path and the symbology you expect
Dim validated = BarcodeValidator.GetValidResults(
"warehouse-scan.png",
expectedType:=BarcodeEncoding.Code128,
confidenceThreshold:=0.7)
If validated.Count = 0 Then
' No valid results; log the failure and skip downstream processing
Return
End If
' All results have passed null, empty, type, and confidence checks
For Each barcode In validated
SendToInventorySystem(barcode.Value, barcode.BarcodeType.ToString()) ' placeholder for your downstream call
Next barcodeImports IronBarCode
Imports System.Collections.Generic
Imports System.Linq
' Reusable validation helper — consolidates null, empty, value, and
' expected-format checks into a single method. Returns an empty list
' (never null) so callers do not need to null-check the return value.
Public Module BarcodeValidator
Public Function GetValidResults(
imagePath As String,
Optional expectedType As BarcodeEncoding? = Nothing,
Optional confidenceThreshold As Double = 0.7) As List(Of BarcodeResult)
' Apply confidence threshold at scan level via BarcodeReaderOptions
Dim options As New BarcodeReaderOptions With {
.ConfidenceThreshold = confidenceThreshold
}
Dim results As BarcodeResults = BarcodeReader.Read(imagePath, options)
' Return empty list instead of null so callers never need to null-check the return value
If results Is Nothing OrElse results.Count = 0 Then
Return New List(Of BarcodeResult)()
End If
Return results _
.Where(Function(r) Not String.IsNullOrWhiteSpace(r.Value)) _ ' skip results with empty decoded data
.Where(Function(r) expectedType Is Nothing OrElse r.BarcodeType = expectedType) _ ' null accepts any symbology
.ToList()
End Function
End Module
' Usage: pass the image path and the symbology you expect
Dim validated = BarcodeValidator.GetValidResults(
"warehouse-scan.png",
expectedType:=BarcodeEncoding.Code128,
confidenceThreshold:=0.7)
If validated.Count = 0 Then
' No valid results; log the failure and skip downstream processing
Return
End If
' All results have passed null, empty, type, and confidence checks
For Each barcode In validated
SendToInventorySystem(barcode.Value, barcode.BarcodeType.ToString()) ' placeholder for your downstream call
Next barcodeMetod, null döndermek yerine boş bir liste döndürür, bu yüzden çağıranlar dönen değeri null kontrol etmek zorunda kalmazlar. İsteğe bağlı expectedType parametresi sembolojiye göre filtreler, böylece bir tarama aynı görüntüden hem bir QR kodu hem de bir Code 128 aldığında, aşağı akış sistemi beklenmedik formatlar almaz.
Çoklu dosya üzerinden seri okuma için, dosya başına aynı deseni uygulayın ve sonuçları biriktirin. ExpectBarcodeTypes seçeneği BarcodeReaderOptions üzerinde, beklenen sembolojilere taramayı başlangıçta daraltır, böylece daha az istenmeyen sonuç doğrulayıcıya ulaşır.
Daha Fazla Okuma
- Barkod Okuma Eğitimi: tarama yapılandırması ve okuma seçenekleri.
- Çıktı Veri Formatları Kılavuzu: tüm
BarcodeResultözellikleri ve türleri. - Veriden Barkod Oluşturma: her semboloji için kodlama kısıtlamaları.
- BarcodeReaderOptions API Referansı: eksiksiz yapılandırma dokümantasyonu.
- IronBarcode Değişiklik Günlüğü: versiyona özgü düzeltmeler ve özellik eklemeleri.
Boru hattı üretime hazır olduğunda lisanslama seçeneklerini görüntüleyin.
Sıkça Sorulan Sorular
IronBarcode içinde BarcodeResults nedir ve null kontrolünü nasıl etkiler?
BarcodeResults, IronBarcode'un BarcodeReader.Read metodunun döndürdüğü bir koleksiyondur. Giriş resmi geçersizse null olacak ve barkod tespit edilmezse boş olacaktır, bu da çalışma zamanı istisnalarını önlemek için uygun bir null kontrolü gerektirir.
IronBarcode işlemlerinde guard cümleleri istisnaları nasıl önler?
Guard cümleleri, hem okuma hem de yazma işlemlerinde, ilerlemeden önce null veya geçersiz girişleri kontrol etmek için uygulanır, bu da üretimde NullReferenceException ve ArgumentException gibi istisnaları önler.
BarcodeWriter.CreateBarcode'a null veya boş bir dize geçerseniz ne olur?
BarcodeWriter.CreateBarcode'a null veya boş bir dize geçirmek hemen bir istisna fırlatır. Çağrıdan önce giriş validasyonu, bu tür istisnaların önlenmesini sağlar ve sabit bir kodlama sürecini korur.
ConfidenceThreshold, IronBarcode'da BarcodeReader'ı nasıl etkiler?
ConfidenceThreshold, tarama sırasında düşük kalite okuma işlemlerini filtreleyen BarcodeReaderOptions'ta bir özelliktir. Bu eşik altındaki okumalar elenir, böylece sonuçlar koleksiyonuna ulaşmazlar ve tarama kalitesini artırır.
IronBarcode, tek bir taramada birden fazla barkod türünü işleyebilir mi?
Evet, IronBarcode tek bir taramada birden fazla türü işleyebilir. ExpectBarcodeTypes gibi ayarlarla BarcodeReaderOptions kullanarak, okuyucuları belirli sembolojilere odaklanarak karışık içerikli görüntüleri etkili bir şekilde yönetebilir.
Downstream işlemden önce BarcodeResults'u doğrulamak neden önemlidir?
BarcodeResults'u doğrulamak, sonuç sayısını, değer bütünlüğünü ve tür tutarlılığını sağlamak, yanlış verilerin veritabanı yazmalarını, API çağrılarını ve diğer sistem etkileşimlerini etkilemesini önler.
IronBarcode işlemlerinde null sonuçları kontrol etmemenin etkisi nedir?
Null sonuçlarını kontrol etmemek, tarama işlemleri sırasında NullReferenceException'lara yol açabilir, çünkü var olmayan bir BarcodeResult'un özelliklerine erişim başarısız olur.
IronBarcode'un yeniden kullanılabilir kontrolör deseni nasıl çalışır?
IronBarcode'un tekrar kullanılabilir kontrolör deseni, null kontrollerini, boş kontrollerini, değer bütünlüğü ve beklenen format doğrulamalarını tek bir yöntem altında birleştirerek, sonuçlar aşağı akımda kullanılmadan önce validasyon sürecini basitleştirir.
BarcodeWriterEncoding, barkod oluşturma sırasında hangi kısıtlamaları ele alır?
BarcodeWriterEncoding, barkod türüne bağlı olarak dize uzunluğu ve karakter geçerliliği gibi kısıtlamalar uygular. Örneğin EAN-8, 7 veya 8 sayısal rakama sahip olmalıdır. Doğru formatlanmış giriş, kodlama sırasında istisnaları önler.
IronBarcode taranmış barkodların kalitesini nasıl sağlar?
IronBarcode, sonuçlarda sadece yüksek kaliteli barkodların yer almasını sağlamak için BarcodeReaderOptions’ta bulunan ConfidenceThreshold gibi özellikler kullanır. Bu ön tarama filtresi, düşük kaliteli okumaların daha fazla işlemden önce elenmesini sağlar.
Curtis Chau, Bilgisayar Bilimleri alanında Lisans Derecesine (Carleton Üniversitesi) sahip ve Node.js, TypeScript, JavaScript ve React konularında uzmanlaşmış ön uç geliştirmeyle ilgileniyor. Sezgisel ve estetik açıdan hoş kullanıcı arayüzleri oluşturma tutkunu, Curtis modern çerçevelerle çalışmayı ve iyi yapılandırılmış, görsel olarak çekici kılavuzlar oluşturmayı seviyor.