Table of Contents

Class Gs1ElementString

Namespace
Egami.Barcodes
Assembly
Egami.Barcodes.dll

One GS1 element string: an Application Identifier and its data field, checked against the GS1 General Specifications (characters, lengths, check digits, dates and times). Parse(string) makes a list of them from text such as (01)09501101530003(17)261231, and the GS1 symbols encode that list.

public sealed class Gs1ElementString : IEquatable<Gs1ElementString>
Inheritance
Gs1ElementString
Implements
Inherited Members

Examples

// Each element string is checked: the AI, the length, the GTIN's check digit, the date.
IReadOnlyList<Gs1ElementString> elements = Gs1.Parse("(01)09501101530003(17)261231(10)AB12");
Barcode label = Barcode.Gs1Code128(elements);

// Mistakes say what is wrong.
if (!Gs1.TryParse("(01)09501101530004", out _))
{
    Console.WriteLine("(01) has a wrong check digit");
}

Properties

Ai

Gets the Application Identifier, 2 to 4 digits, such as 01 for a GTIN.

public string Ai { get; }

Property Value

string

Title

Gets GS1's short title for the AI, such as GTIN or BATCH/LOT.

public string Title { get; }

Property Value

string

Value

Gets the data field.

public string Value { get; }

Property Value

string

Methods

Create(string, string)

Makes an element string from an AI and its data field, and checks it.

public static Gs1ElementString Create(string ai, string value)

Parameters

ai string

The Application Identifier, such as 01.

value string

The data field.

Returns

Gs1ElementString

The element string.

Exceptions

FormatException

GS1 does not define the AI, or the data does not fit it; the message says how.

Equals(Gs1ElementString?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Gs1ElementString? other)

Parameters

other Gs1ElementString

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ToString()

Returns the element string in its human-readable form, the AI in parentheses: (01)09501101530003.

public override string ToString()

Returns

string

The text.