Using IronBarcode With C#, VB.NET & F

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

IronBarcode is built on .NET Standard 2.0, so it works natively with C#, VB.NET, and F# without additional configuration. The API surface is consistent across all three languages. Every method, class, and property available in C# is also accessible in VB.NET and F# projects.

安裝

Install IronBarcode from NuGet:

Install-Package BarCode

The same BarCode package works for all three languages. No language-specific packages are required.

C# Example

C# is the most widely used language with IronBarcode. This example generates a QR code and saves it as a 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

輸出

QR code encoding https://ironsoftware.com generated by IronBarcode in C#
Console output showing https://ironsoftware.com decoded from the generated QR code

QRCodeWriter.CreateQrCode produces a 250×250 QR code that BarcodeReader.Read decodes back to https://ironsoftware.com.

VB.NET Example

VB.NET uses the same IronBarcode methods as C#. Only the syntax changes:

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

The output is identical to the C# example above.

VB.NET is supported across both .NET Framework and .NET Core projects. For a detailed walkthrough, see the VB.NET barcode generation tutorial.

F# Example

F# developers can reference IronBarcode directly. The library works in standard F# projects and in F# Interactive using the #r directive:

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#

The output is identical to the C# example above.

支援的 .NET 版本

IronBarcode supports a wide range of .NET runtimes across all three languages:

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

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

常見問題解答

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.

IronBarcode支援哪些.NET版本?

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
技術作家

Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。

準備好開始了嗎?
Nuget 下載 2,143,620 | 版本: 2026.4 剛剛發布
Still Scrolling Icon

還在捲動嗎?

想要快速證明? PM > Install-Package BarCode
執行範例 看您的字串變成 BarCode。