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
- Creating an Index From the End of a Collection at a Specified Index Position in C#
- Creating an Index From the Specified Index at the Start of a Collection in C#
- Range Constructor in C#
- C# | Default Constructor
- C# | Copy Constructor
- C# | Constructor Overloading
- C# | Thread(ThreadStart) Constructor
- C# | Thread(ParameterizedThreadStart) Constructor
- Invoking an overloaded constructor using this keyword in C#
- How to get the index value in C#?
- C# | Get or Set at specified index in StringCollection
- Index Struct in C# 8.0
- C# | Remove from the specified index of a SortedList
- C# | Insert at the specified index in StringCollection
- Finding the End Index of the Specified Range in C#
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.