Używanie IronBarcode z C#, VB.NET i F

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronBarcode jest zbudowane na .NET Standard 2.0, więc działa natywnie z C#, VB.NET i F# bez dodatkowej konfiguracji. Powierzchnia API jest spójna we wszystkich trzech językach. Każda metoda, klasa i właściwość dostępna w C# jest również dostępna w projektach VB.NET i F#.

Instalacja

Zainstaluj IronBarcode z NuGet:

Install-Package BarCode

Ten sam pakiet BarCode działa we wszystkich trzech językach. Nie są wymagane pakiety specyficzne dla języka.

Przykład C

C# jest najczęściej używanym językiem z IronBarcode. Ten przykład generuje kod QR i zapisuje go jako PNG:

:path=/static-assets/barcode/content-code-examples/get-started/net-language-support/net-language-support.cs
using IronBarCode;

// Generate a QR code and save it as an image
var qrCode = QRCodeWriter.CreateQrCode("https://ironsoftware.com", 250);
qrCode.SaveAsPng("qr-code.png");

// Read the barcode back from the saved image
var result = BarcodeReader.Read("qr-code.png");
Console.WriteLine(result.First().Value);
Imports IronBarCode

' Generate a QR code and save it as an image
Dim qrCode = QRCodeWriter.CreateQrCode("https://ironsoftware.com", 250)
qrCode.SaveAsPng("qr-code.png")

' Read the barcode back from the saved image
Dim result = BarcodeReader.Read("qr-code.png")
Console.WriteLine(result.First().Value)
$vbLabelText   $csharpLabel

Wynik

Kod QR kodujący https://ironsoftware.com wygenerowany przez IronBarcode w C#
Wyjście konsoli pokazujące https://ironsoftware.com zdekodowane z wygenerowanego kodu QR

QRCodeWriter.CreateQrCode produkuje 250×250 kod QR, który BarcodeReader.Read dekoduje z powrotem do https://ironsoftware.com.

Przykład VB.NET

VB.NET używa tych samych metod IronBarcode, co C#. Zmienia się jedynie składnia:

Imports IronBarCode

' Generate a QR code and save it as an image
Dim qrCode = QRCodeWriter.CreateQrCode("https://ironsoftware.com", 250)
qrCode.SaveAsPng("qr-code.png")

' Read the barcode back from the saved image
Dim result = BarcodeReader.Read("qr-code.png")
Console.WriteLine(result.First().Value)
Imports IronBarCode

' Generate a QR code and save it as an image
Dim qrCode = QRCodeWriter.CreateQrCode("https://ironsoftware.com", 250)
qrCode.SaveAsPng("qr-code.png")

' Read the barcode back from the saved image
Dim result = BarcodeReader.Read("qr-code.png")
Console.WriteLine(result.First().Value)
Imports IronBarCode

' Generate a QR code and save it as an image
Dim qrCode = QRCodeWriter.CreateQrCode("https://ironsoftware.com", 250)
qrCode.SaveAsPng("qr-code.png")

' Read the barcode back from the saved image
Dim result = BarcodeReader.Read("qr-code.png")
Console.WriteLine(result.First().Value)
$vbLabelText   $csharpLabel

Wynik jest identyczny z powyższym przykładem C#.

VB.NET jest obsługiwany zarówno w projektach .NET Framework, jak i .NET Core. Aby uzyskać szczegółowy przegląd, zobacz samouczek generowania kodu kreskowego VB.NET.

Przykład F

Deweloperzy F# mogą odwołać się bezpośrednio do IronBarcode. Biblioteka działa w projektach standardowych F# oraz w F# Interactive przy użyciu dyrektywy #r:

open IronBarCode

// Generate a QR code and save it as an image
let qrCode = QRCodeWriter.CreateQrCode("https://ironsoftware.com", 250)
qrCode.SaveAsPng("qr-code.png")

// Read the barcode back from the saved image
let result = BarcodeReader.Read("qr-code.png")
printfn "%s" (result.First().Value)
open IronBarCode

// Generate a QR code and save it as an image
let qrCode = QRCodeWriter.CreateQrCode("https://ironsoftware.com", 250)
qrCode.SaveAsPng("qr-code.png")

// Read the barcode back from the saved image
let result = BarcodeReader.Read("qr-code.png")
printfn "%s" (result.First().Value)
F#

Wynik jest identyczny z powyższym przykładem C#.

Obsługiwane wersje .NET

IronBarcode obsługuje szeroki zakres środowisk uruchomieniowych .NET we wszystkich trzech językach:

  • .NET 9, 8, 7, 6, 5
  • .NET Core 3.x, 2.x
  • .NET Framework 4.6.2+
  • .NET Standard 2.0

Dla specyficznych dla platformy pakietów NuGet (Windows, Linux, macOS, iOS, Android) zapoznaj się z przewodnikiem zaawansowanej instalacji.

Często Zadawane Pytania

What languages are supported by IronBarcode?

IronBarcode supports C#, VB.NET, and F# with an identical API, making it versatile across different .NET languages.

How do I install IronBarcode?

You can install IronBarcode from NuGet using the package manager for your respective language environment with the command `Install-Package BarCode`.

Can I use IronBarcode with .NET Core and .NET Framework?

Yes, IronBarcode is compatible with both .NET Core and .NET Framework, supporting .NET Core 3.x, 2.x, and .NET Framework 4.6.2+.

Is there a difference in using IronBarcode between C#, VB.NET, and F#?

The API surface is identical across C#, VB.NET, and F#, so the functionality remains the same, with only syntax differences.

How can I generate a QR code using C# with IronBarcode?

In C#, you can generate a QR code using IronBarcode by calling `QRCodeWriter.CreateQrCode("https://ironsoftware.com", 250)` and saving it with `qrCode.SaveAsPng("qr-code.png")`.

Is IronBarcode compatible with F# Interactive?

Yes, IronBarcode can be used in F# Interactive by referencing it directly with the `#r` directive.

Jakie wersje .NET obsługuje IronBarcode?

IronBarcode supports a wide range of .NET versions including .NET 9, 8, 7, 6, 5, .NET Core 3.x, 2.x, and .NET Framework 4.6.2+.

Do I need language-specific packages to use IronBarcode?

No, the same `BarCode` package from NuGet works for C#, VB.NET, and F# without the need for language-specific packages.

How do I read a barcode from an image using VB.NET?

Using VB.NET, you can read a barcode from an image with IronBarcode by calling `BarcodeReader.Read("qr-code.png")` and accessing the result.

Are there platform-specific installation guides for IronBarcode?

Yes, for platform-specific NuGet packages (Windows, Linux, macOS, iOS, Android), you can refer to the advanced installation guide.

Curtis Chau
Autor tekstów technicznych

Curtis Chau posiada tytuł licencjata z informatyki (Uniwersytet Carleton) i specjalizuje się w front-endowym rozwoju, z ekspertką w Node.js, TypeScript, JavaScript i React. Pasjonuje się tworzeniem intuicyjnych i estetycznie przyjemnych interfejsów użytkownika, Curtis cieszy się pracą z nowoczesnymi frameworkami i tworzeniem dobrze zorganizowanych, atrakcyjnych wizualnie podrę...

Czytaj więcej
Gotowy, aby rozpocząć?
Nuget Pliki do pobrania 2,145,441 | Wersja: 2026.4 just released
Still Scrolling Icon

Wciąż przewijasz?

Czy chcesz szybko dowodu? PM > Install-Package BarCode
uruchom przykład zobacz, jak twoje ciągi zamieniają się w kody kreskowe.