How to Create a Range to a Specified End in C#? Last Updated : 28 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The Range Structure is introduced in C# 8.0. It represents a range that has a start and end indexes. You are allowed to a Range object starting from the first element of the specified collection or sequence to a specified end index with the help of EndAt() Method provided by the Range structure. Or in other words, EndAt() method returns a range that starts from the first element of the given collection and ends to the specified index. Syntax: public static Range EndAt(Index end); Here, the Index end represents the end index. Example 1: CSharp // C# program to illustrate how // to create a range using // EndAt() method of Range struct using System; namespace range_example { class GFG { // Main Method static void Main(string[] args) { // Creating range // using Range constructor var r1 = new Range(2, 4); // Creating range // using Range operator Range r2 = 1..10; // Creating a range // using EndAt() method var r3 = Range.EndAt(6); // Displaying all the ranges Console.WriteLine("Range_1: " + r1); Console.WriteLine("Range_2: " + r2); Console.WriteLine("Range_3: " + r3); } } } Output: Range_1: 2..4 Range_2: 1..10 Range_3: 0..6 Example 2: CSharp // C# program to illustrate // how to create a range using // EndAt() method of Range struct using System; namespace range_example { class GFG { // Main Method static void Main(string[] args) { // Creating and initializing an array int[] arr = new int[8] {100, 200, 300, 400, 500, 600, 700, 800}; // Creating a range // using EndAt() method var r = Range.EndAt(5); var new_arr = arr[r]; // Displaying the range // and the elements Console.WriteLine("Range: " + r); Console.Write("Numbers: "); foreach(var i in new_arr) Console.Write($" [{i}]"); } } } Output: Range: 0..5 Numbers: [100] [200] [300] [400] [500] Comment More infoAdvertise with us Next Article How to Create a Range to a Specified End in C#? ankita_saini Follow Improve Article Tags : C# CSharp-8.0 Similar Reads How to Create a Range From a Specified Start in C#? The Range Structure is introduced in C# 8.0. It represents a range that has a start and end indexes. You are allowed to create a Range object starting from the specified starting index to the end of the given collection or sequence with the help of the StartAt() Method provided by the Range structur 2 min read Getting the Hash Code of the Specified Range in C# The Range Structure is introduced in C# 8.0. It represents a range that has a start and end indexes. You are allowed to get the hash code of the specified range with the help of the GetHashCode() Method provided by the Range struct. This method returns the hash code of the specified instance. Syntax 2 min read Finding the End Index of the Specified Range in C# The Range Structure is introduced in C# 8.0. It represents a range that has a start and end indexes. You are allowed to find the end index of the given ranges with the help of End Property provided by the Range struct.Syntax:Â Â public property Index End { Index get(); }; Here, Index represents the e 2 min read C# | How to insert the elements of a collection into the List at the specified index List<T>.InsertRange(Int32, IEnumerable<T>) Method is used to insert the elements of a collection into the List<T> at the specified index. Properties of List: It is different from the arrays. A list can be resized dynamically but arrays cannot. List class can accept null as a valid 3 min read Finding all the Elements of a Range from Start to End in C# The Range Structure is introduced in C# 8.0. It represents a range that has a start and end indexes. You are allowed to find all the range object starting from the start index to end with the help of All Property provided by the Range struct. This property always returns 0..^0 range.Syntax:Â Â public 2 min read Finding the Start Index of the Specified Range in C# The Range Structure is introduced in C# 8.0. It represents a range that has start and end indexes. You are allowed to find the start index of the given range with the help of the Start Property provided by the Range struct.Syntax:Â Â public property Index Start { Index get(); }; Here, Index represent 2 min read Creating an Index From the End of a Collection at a Specified Index Position in C# The Index Structure is introduced in C# 8.0. It represents a type that can be used to index a collection or sequence and it can be started from the start or the end. You are allowed to create an end index with the help of the FromEnd(Int32) Method provided by the Index struct. This method returns an 2 min read Creating an Index From the Specified Index at the Start of a Collection in C# The Index Structure is introduced in C# 8.0. It represents a type that can be used to index a collection or sequence and it can be started from the start or the end. You are allowed to create a start index with the help of the FromStart(Int32) Method() provided by the Index struct. This method retur 2 min read C# | Copy the elements of a string array to the end of the StringCollection StringCollection class is a new addition to the .NET Framework class library that represents a collection of strings. StringCollection class is defined in the System.Collections.Specialized namespace. StringCollection.AddRange(String[]) method is used to copy the elements of a string array to the en 2 min read C# | Remove a range of elements from the ArrayList ArrayList represents an ordered collection of an object that can be indexed individually. It is basically an alternative to an array. It also allows dynamic memory allocation, adding, searching and sorting items in the list. ArrayList.RemoveRange(Int32, Int32) method is used to remove a range of ele 3 min read Like