Range Constructor in C# Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Range(Index, Index) Constructor is the part of Range Struct. This constructor is used to create a new instance of Range along with the specified starting and ending indexes. When you create a range using the range operator or constructor, then it will not add the last element or end index element. For example, we have an array {1, 2, 3, 4, 5, 6 }, now we want to print range[1..3], then it will print 2, 3. It does not print 2, 3, 4.Syntax: public Range(Index start, Index end); Here, the start represents the starting index of the range and the end represents the last index of the range.Example 1: CSharp // C# program to illustrate how to // use Range(Index, Index) constructor using System; namespace range_example { class GFG { // Main Method static void Main(string[] args) { // Creating and initializing an array int[] arr = new int[10] {23, 45, 67, 78, 89, 34, 89, 43, 67, 89}; Index start = 2; Index end = 5; // Creating range // Using Range(Index, // Index) Constructor var r = new Range(start, end); var value = arr[r]; // Displaying range and elements Console.WriteLine("Range: " + r); Console.Write("Numbers: "); foreach(var i in value) Console.Write($" {i}, "); } } } Output: Range: 2..5 Numbers: 67, 78, 89, Example 2: CSharp // C# program to illustrate how to // use Range(Index, Index) constructor using System; namespace range_example { class Program { // Main Method static void Main(string[] args) { // Creating and initializing an array string[] arr = new string[8] {"Archery", "Badminton", "Cricket", "Bowling", "Boxing", "Curling", "Tennis", "Skateboarding"}; // Creating ranges // Using Range(Index, // Index) Constructor var r1 = new Range(0, 3); var r2 = new Range(4, 7); var value_1 = arr[r1]; var value_2 = arr[r2]; // Displaying range and elements Console.WriteLine("Range: " + r1); Console.Write("Sports Name: "); foreach(var i_1 in value_1) Console.Write($" {i_1} "); Console.WriteLine("\n\nRange: " + r2); Console.Write("Sports Name: "); foreach(var i_2 in value_2) Console.Write($" {i_2} "); } } } Output: Range: 0..3 Sports Name: Archery Badminton Cricket Range: 4..7 Sports Name: Boxing Curling Tennis Comment More infoAdvertise with us Next Article Range and Indices in C# 8.0 A ankita_saini Follow Improve Article Tags : C# CSharp-8.0 Similar Reads 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 3 min read C# UInt32 Struct In C#, the UInt32 struct represents a 32-bit unsigned integer (commonly referred to as the uint data type). It is defined in the System namespace and provides various methods for mathematical computations, parsing, and type conversion. Because of it is an unsigned type, it only holds non-negative va 2 min read C# UInt16 Struct In C#, the UInt16 struct, defined under the System namespace, represents a 16-bit unsigned integer, commonly referred to as the ushort data type. It does not support negative values and provides a range from 0 to 65,535. The UInt16 struct inherits the ValueType class, which further inherits the Obje 2 min read C# | Operator Overloading Prerequisite: Operators in C# The concept of overloading a function can also be applied to operators. Operator overloading gives the ability to use the same operator to do various operations. It provides additional capabilities to C# operators when they are applied to user-defined data types. It ena 4 min read Range and Indices in C# 8.0 Range and Indices introduced in C# 8.0. released as part of .NET Core 3.0 and .NET Framework 4.8 they provide a short syntax to represent or access a single or a range of elements from the given sequence or collections. System.Index: It represents an index in the given sequence or collection.System. 4 min read C# Int32 Struct In C#, the Int32 struct represents a 32-bit signed integer and is commonly used as the int data type. It belongs to the System namespace and provides various methods to perform operations like mathematical computations, parsing, and type conversion. The Int32 struct inherits from ValueType, which in 3 min read Like