Link Search Menu Expand Document

QR Code with Sms Message - C#

BarCode SDK sample in C# demonstrating ‘QR Code with Sms Message’

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;

            // Inputs
            var inputNumber = "393-235-2333";
            var inputMessage = "Hello There!";

            // Set value            
            barcode.Value = new QrCodeSmsTemplate(inputNumber, inputMessage).ToString();

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

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

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

namespace CreateBarCode
{
    class QrCodeSmsTemplate
    {
        #region Constructors

        public QrCodeSmsTemplate() { }
        public QrCodeSmsTemplate(string Number, string Message)
        {
            this.Number = Number;
            this.Message = Message;
        }

        #endregion

        #region Properties

        public string Number { get; set; }
        public string Message { get; set; }

        #endregion

        #region Overloaded Methods

        public override string ToString()
        {
            if (string.IsNullOrEmpty(Number) && string.IsNullOrEmpty(Message))
                return base.ToString();

            return $"smsto:{Number}:{Message}";
        }

        #endregion
    }
}

Download Source Code (.zip)

Return to the previous page Explore BarCode SDK


Copyright © 2016 - 2021 ByteScout