Link Search Menu Expand Document

QR Code with Website Url - C#

BarCode SDK sample in C# demonstrating ‘QR Code with Website Url’

Program.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

using Bytescout.BarCode;
using CreateBarCode;

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create new barcode
            Barcode barcode = new Barcode();

            // Set symbology
            barcode.Symbology = SymbologyType.QRCode;

            // Input Url
            var inputUrl = "https://bytescout.com";

            // Set value            
            barcode.Value = new QrCodeUrlTemplate(inputUrl).ToString();

            // Save barcode to image
            barcode.SaveImage("result.png");

            // Show image in default image viewer
            Process.Start("result.png");
        }
    }
}

QrCodeUrlTemplate.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CreateBarCode
{
    class QrCodeUrlTemplate
    {
        #region Constructors

        public QrCodeUrlTemplate() { }
        public QrCodeUrlTemplate(string Url) { this.Url = Url; }

        #endregion

        #region Properties

        public string Url { get; set; }

        #endregion

        #region Overloaded Methods

        public override string ToString()
        {
            if(string.IsNullOrEmpty(Url))
            return base.ToString();

            return Url;
        }

        #endregion
    }
}

Download Source Code (.zip)

Return to the previous page Explore BarCode SDK