Index Constructor in C#
Index(Int32, Boolean) constructor of Index Struct in C# 8.0 is used to initialize a new index with the specified index position and a value which shows whether the index starts from the start or the end of the collection or sequence. If the specified index created from the end, then the index value of 1 will point to the last element and the index value of 0 will point beyond the last element.
public Index (int Value, bool FromEnd = false);
Here, Value is of index value and it is of System.Int32 type. The value of the index should be equal to or greater than zero. FromEnd is the boolean value which indicates that if the index starts from the start or from the end of the collection or sequence. Below codes executed on C# 8.0 or above versions:
Index:^1 Value: Ahnyounghaseyo Index:^2 Value: Ohayo Index:^3 Value: Bonjour Index:1 Value: Hola Index:2 Value: Namaste Index:3 Value: Bonjour
Index:^1 Start from end?: True Index:^2 Start from end?: True Index:1 Start from end?: False Index:2 Start from end?: False