QRCode Class

Represents a generated QR code as a boolean matrix of modules.

public sealed class QRCode

Properties

NameDescription
ErrorCorrectionLevelGets the error correction level the symbol was built with.
HeightGets the height (number of rows).
SizeGets the side length for square QR codes (same as QRCode.Width).
TypeGets the type of QR code.
VersionGets the QR code version.
WidthGets the width (number of columns).

ErrorCorrectionLevel

QRCode.cs

Gets the error correction level the symbol was built with.

public ErrorCorrectionLevel ErrorCorrectionLevel { get; }

Property value

ErrorCorrectionLevel

Remarks

This can differ from the requested level. Micro QR version M1 carries error detection only, and is reported as ErrorCorrectionLevel.L because the enumeration has no weaker member.

Height

QRCode.cs

Gets the height (number of rows).

public int Height { get; }

Property value

int

Gets the side length for square QR codes (same as QRCode.Width).

public int Size { get; }

Property value

int

Gets the type of QR code.

public QRCodeType Type { get; }

Property value

QRCodeType

Version

QRCode.cs

Gets the QR code version.

public int Version { get; }

Property value

int

Gets the width (number of columns).

public int Width { get; }

Property value

int

Indexers

NameDescription
this[int, int]Gets whether the module at the specified position is dark.

this[int, int]

QRCode.cs

Gets whether the module at the specified position is dark.

public bool this[int row, int column] { get; }

Parameters

row int
The row index (0-based).
column int
The column index (0-based).

Property value

bool

Methods

NameDescription
Create(ReadOnlySpan<byte>, ErrorCorrectionLevel)Creates a standard QR code from the specified binary data.
Create(ReadOnlySpan<byte>, ErrorCorrectionLevel, QRCodeOptions?)Creates a standard QR code from the specified binary data.
Create(string, ErrorCorrectionLevel)Creates a standard QR code from the specified text data.
Create(string, ErrorCorrectionLevel, QRCodeOptions?)Creates a standard QR code from the specified text data.
CreateMicroQR(string, ErrorCorrectionLevel)Creates a Micro QR code from the specified text data. Micro QR codes are smaller (versions M1-M4, 11x11 to 17x17 modules) and have a single finder pattern.
CreateMicroQR(string, ErrorCorrectionLevel, MicroQRCodeOptions?)Creates a Micro QR code from the specified text data. Micro QR codes are smaller (versions M1-M4, 11x11 to 17x17 modules) and have a single finder pattern.
CreateRMQR(string, ErrorCorrectionLevel)Creates a Rectangular Micro QR code (rMQR) from the specified text data. rMQR codes are rectangular and optimized for narrow spaces.
CreateRMQR(string, ErrorCorrectionLevel, RMQRCodeOptions?)Creates a Rectangular Micro QR code (rMQR) from the specified text data. rMQR codes are rectangular and optimized for narrow spaces.

Create overloads

Create(ReadOnlySpan<byte>, ErrorCorrectionLevel)

QRCode.cs

Creates a standard QR code from the specified binary data.

public static QRCode Create(ReadOnlySpan<byte> data, ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.M)
Parameters
data ReadOnlySpan<byte>
The binary data to encode.
errorCorrectionLevel ErrorCorrectionLevel
The error correction level.
Returns

QRCode A new QRCode instance.

Exceptions
ArgumentOutOfRangeException
errorCorrectionLevel is not a defined ErrorCorrectionLevel value.

Create(ReadOnlySpan<byte>, ErrorCorrectionLevel, QRCodeOptions?)

QRCode.cs

Creates a standard QR code from the specified binary data.

public static QRCode Create(ReadOnlySpan<byte> data, ErrorCorrectionLevel errorCorrectionLevel, QRCodeOptions? options)
Parameters
data ReadOnlySpan<byte>
The binary data to encode.
errorCorrectionLevel ErrorCorrectionLevel
The error correction level.
options QRCodeOptions?
The options, or null for the defaults.
Returns

QRCode A new QRCode instance.

Exceptions
ArgumentOutOfRangeException
errorCorrectionLevel is not a defined ErrorCorrectionLevel value.
ArgumentException
QRCodeOptions.MinimumVersion is greater than QRCodeOptions.MaximumVersion.
InvalidOperationException
The data does not fit in the largest allowed version.
Remarks

The bytes are encoded as they are, in byte mode, preceded by an ECI designator when QRCodeOptions.EciAssignmentNumber is set.

Create(string, ErrorCorrectionLevel)

QRCode.cs

Creates a standard QR code from the specified text data.

public static QRCode Create(string data, ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.M)
Parameters
data string
The text data to encode.
errorCorrectionLevel ErrorCorrectionLevel
The error correction level.
Returns

QRCode A new QRCode instance.

Exceptions
ArgumentOutOfRangeException
errorCorrectionLevel is not a defined ErrorCorrectionLevel value.

Create(string, ErrorCorrectionLevel, QRCodeOptions?)

QRCode.cs

Creates a standard QR code from the specified text data.

public static QRCode Create(string data, ErrorCorrectionLevel errorCorrectionLevel, QRCodeOptions? options)
Parameters
data string
The text data to encode.
errorCorrectionLevel ErrorCorrectionLevel
The error correction level.
options QRCodeOptions?
The options, or null for the defaults.
Returns

QRCode A new QRCode instance.

Exceptions
ArgumentOutOfRangeException
errorCorrectionLevel is not a defined ErrorCorrectionLevel value.
ArgumentException
QRCodeOptions.EciAssignmentNumber is not null or QRCodeOptions.Utf8EciAssignmentNumber, or QRCodeOptions.MinimumVersion is greater than QRCodeOptions.MaximumVersion.
InvalidOperationException
The data does not fit in the largest allowed version.
Remarks

The text is encoded as UTF-8, without an ECI designator unless QRCodeOptions.EciAssignmentNumber is QRCodeOptions.Utf8EciAssignmentNumber.

CreateMicroQR overloads

CreateMicroQR(string, ErrorCorrectionLevel)

QRCode.cs

Creates a Micro QR code from the specified text data. Micro QR codes are smaller (versions M1-M4, 11x11 to 17x17 modules) and have a single finder pattern.

public static QRCode CreateMicroQR(string data, ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L)
Parameters
data string
The text data to encode.
errorCorrectionLevel ErrorCorrectionLevel
The error correction level. M1 only supports detection; M2/M3 support L/M; M4 supports L/M/Q.
Returns

QRCode A new QRCode instance.

Exceptions
ArgumentOutOfRangeException
errorCorrectionLevel is not ErrorCorrectionLevel.L, ErrorCorrectionLevel.M or ErrorCorrectionLevel.Q.

CreateMicroQR(string, ErrorCorrectionLevel, MicroQRCodeOptions?)

QRCode.cs

Creates a Micro QR code from the specified text data. Micro QR codes are smaller (versions M1-M4, 11x11 to 17x17 modules) and have a single finder pattern.

public static QRCode CreateMicroQR(string data, ErrorCorrectionLevel errorCorrectionLevel, MicroQRCodeOptions? options)
Parameters
data string
The text data to encode.
errorCorrectionLevel ErrorCorrectionLevel
The error correction level. M1 only supports detection; M2/M3 support L/M; M4 supports L/M/Q.
options MicroQRCodeOptions?
The options, or null for the defaults.
Returns

QRCode A new QRCode instance.

Exceptions
ArgumentOutOfRangeException
errorCorrectionLevel is not ErrorCorrectionLevel.L, ErrorCorrectionLevel.M or ErrorCorrectionLevel.Q.
ArgumentException
MicroQRCodeOptions.MinimumVersion is greater than MicroQRCodeOptions.MaximumVersion, or no version of this range supports errorCorrectionLevel.
InvalidOperationException
The data does not fit in the largest allowed version, or has characters these versions cannot encode.

CreateRMQR overloads

CreateRMQR(string, ErrorCorrectionLevel)

QRCode.cs

Creates a Rectangular Micro QR code (rMQR) from the specified text data. rMQR codes are rectangular and optimized for narrow spaces.

public static QRCode CreateRMQR(string data, ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.M)
Parameters
data string
The text data to encode.
errorCorrectionLevel ErrorCorrectionLevel
The error correction level. Only M and H are supported.
Returns

QRCode A new QRCode instance.

Exceptions
ArgumentOutOfRangeException
errorCorrectionLevel is not ErrorCorrectionLevel.M or ErrorCorrectionLevel.H.

CreateRMQR(string, ErrorCorrectionLevel, RMQRCodeOptions?)

QRCode.cs

Creates a Rectangular Micro QR code (rMQR) from the specified text data. rMQR codes are rectangular and optimized for narrow spaces.

public static QRCode CreateRMQR(string data, ErrorCorrectionLevel errorCorrectionLevel, RMQRCodeOptions? options)
Parameters
data string
The text data to encode.
errorCorrectionLevel ErrorCorrectionLevel
The error correction level. Only M and H are supported.
options RMQRCodeOptions?
The options, or null for the defaults.
Returns

QRCode A new QRCode instance.

Exceptions
ArgumentOutOfRangeException
errorCorrectionLevel is not ErrorCorrectionLevel.M or ErrorCorrectionLevel.H.
ArgumentException
No rMQR size satisfies the size constraints of options.
InvalidOperationException
The data does not fit in the largest allowed size.