C# 8.0 introduced a new predefined structure that is known as Range struct. This struct is used to represent a range that has a start and end indexes. It provides a new style to create a range using .. operator. This operator is used to create a range that has a starting and ending index. Also with the help of the Range struct you are allowed to create a variable of the range type.
Marks List 1: 45 67 88 99 Marks List 2: 27 67 Marks List 3: 67 88 Marks List 4: 99 56 27
|Range(Index, Index)||This constructor is used to create a new Range instance with the specified starting and ending indexes.|
|All||This property is used to get a Range object that starts from the first element to the end.|
|End||This property is used to get an Index that represents the exclusive end index of the range.|
|Start||This property is used to get the inclusive start index of the Range.|
|EndAt(Index)||This method is used to create a Range object starting from the first element in the collection to a specified end index.|
|Equals()||This method is used to check whether the current range is equal to a specified range.|
|GetHashCode()||This method is used to find the hash code for this instance.|
|GetOffsetAndLength(Int32)||This method is used to calculate the start offset and length of the given range object with the help of a collection length.|
|StartAt(Index)||This method is used to create a new Range instance starting from a specified start index to the end of the collection.|
|ToString()||This method returns the string representation of the current Range object.|
- Difference between Class and Structure in C#
- How to access structure elements using Pointers in C#
- Range Constructor in C#
- C# | Remove a range of elements from the ArrayList
- C# | Reverse the order of the elements in the entire ArrayList or in the specified range
- C# | Removing a range of elements from the List
- C# | Reverse the order of the elements in the entire List or in the specified range
- C# | Copy the elements of collection over a range of elements in ArrayList
- C# | Getting an enumerator for a range of elements in the ArrayList
- LINQ | Generation Operator | Empty, Range, and Repeat
- Getting the Hash Code of the Specified Range in C#
- Finding all the Elements of a Range from Start to End in C#
- Finding the End Index of the Specified Range in C#
- Finding the Start Index of the Specified Range in C#
- How to Create a Range From a Specified Start in C#?
- How to Create a Range to a Specified End in C#?
- Range and Indices in C# 8.0
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.