QR Code with Message - C#
BarCode SDK sample in C# demonstrating ‘QR Code with 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;
// Input Message
var oMessage = new QrCodeMessageTemplate { Message = "Here goes sample message...!" };
// Set value
barcode.Value = oMessage.ToString();
// Save barcode to image
barcode.SaveImage("result.png");
// Show image in default image viewer
Process.Start("result.png");
}
}
}
QrCodeMessageTemplate.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CreateBarCode
{
class QrCodeMessageTemplate
{
#region Constructors
public QrCodeMessageTemplate() { }
public QrCodeMessageTemplate(string Url) { this.Message = Url; }
#endregion
#region Properties
public string Message { get; set; }
#endregion
#region Overloaded Methods
public override string ToString()
{
if(string.IsNullOrEmpty(Message))
return base.ToString();
return Message;
}
#endregion
}
}