Class Gs1ElementString
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
Title
Gets GS1's short title for the AI, such as GTIN or BATCH/LOT.
public string Title { get; }
Property Value
Value
Gets the data field.
public string Value { get; }
Property Value
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
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
otherGs1ElementStringAn object to compare with this object.
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
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.