How to Generate QR Codes in C# .NET Framework

Cloudmersive
2 min readFeb 8, 2024

--

The free-form text encoding that QR codes offer helps bridge the gap between physical and digital worlds. With the help of a low-code API, we can generate our own QR codes at scale to accompany any text (or URLs) of our choosing.

Using the code examples provided below, we can call a free API that generates QR codes as PNG images based on our choice of text input. We can generate up to 800 QR code images per month with a free API key, so we can easily take care of small-scale needs for our business or personal use case.

Once we have a free API key, we can begin by installing the SDK. Let’s install via NuGet by running the below command in our Package Manager console:

Install-Package Cloudmersive.APIClient.NET.Barcode -Version 3.0.2

With installation complete, we can now call the function. Let’s go ahead and copy the below code into our file & include our API key and text inputs in the appropriate fields:

using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NET.Barcode.Api;
using Cloudmersive.APIClient.NET.Barcode.Client;
using Cloudmersive.APIClient.NET.Barcode.Model;

namespace Example
{
public class GenerateBarcodeQRCodeExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");

var apiInstance = new GenerateBarcodeApi();
var value = value_example; // string | QR code text to convert into the QR code barcode

try
{
// Generate a QR code barcode as PNG file
byte[] result = apiInstance.GenerateBarcodeQRCode(value);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling GenerateBarcodeApi.GenerateBarcodeQRCode: " + e.Message );
}
}
}
}

Now we’re all set — we can easily churn out new QR codes without worrying about cost or coding overhead.

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.