IronBarcode を C#, VB.NET & F# で使用する

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

IronBarcodeは.NET Standard 2.0に基づいて構築されているため、追加の設定なしでC#、VB.NET、F#とネイティブに連携します。 3つの言語すべてにおいて、APIのインターフェースは一貫しています。 C# で利用可能なすべてのメソッド、クラス、プロパティは、VB.NET および F# プロジェクトでも利用可能です。

インストール

NuGetからIronBarcodeをインストールする:

Install-Package BarCode

同じ BarCode パッケージが、これら3つの言語すべてに対応しています。 言語固有のパッケージは必要ありません。

C# の例

IronBarcodeでは、C#が最も広く使用されている言語です。 この例では、QRコードを生成し、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

出力

C#でIronBarcodeを使用して生成されたQRコードエンコーディング https://ironsoftware.com
生成されたQRコードからデコードされたhttps://ironsoftware.comを示すコンソール出力

QRCodeWriter.CreateQrCode は 250×250 の QR コードを生成し、BarcodeReader.Read がそれをデコードして https://ironsoftware.com に変換します。

VB.NET の例

VB.NETでは、C#と同じIronBarcodeメソッドが使用されます。 変更されるのは構文のみです:

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

出力は、上記の C# の例と同一です。

VB.NET は .NET Framework と .NET Core プロジェクトの両方でサポートされています。 詳細な手順については、VB.NET バーコード生成チュートリアルをご覧ください。

F# の例

F# 開発者は IronBarcode を直接参照できます。 このライブラリは、標準的な F# プロジェクトおよび #r ディレクティブを使用した F# Interactive で動作します:

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#

出力は、上記の C# の例と同一です。

サポートされている .NET バージョン

IronBarcode は、3 つの言語すべてで広範な .NET ランタイムをサポートしています:

  • .NET 9、8、7、6、5
  • .NET Core 3.x、2.x
  • .NET Framework 4.6.2+
  • .NET Standard2.0

プラットフォーム固有の NuGet パッケージ(Windows, Linux, macOS, iOS, Android)については、高度なインストールガイドを参照してください。

よくある質問

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 はど for .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は、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。

準備はできましたか?
Nuget ダウンロード 2,143,620 | バージョン: 2026.4 リリース
Still Scrolling Icon

まだスクロールしていますか?

すぐに証拠が欲しいですか? PM > Install-Package BarCode
サンプルを実行する 文字列が BarCode になるのを見る。