IndexRange 1.1.1

About

This package lets you use the C# 8.0 index and range features in projects that target .NET Framework.

For projects that target netstandard2.0 or .NET Framework 4.6.2 or later, use the Microsoft.Bcl.Memory package instead. This package should be considered deprecated for those target frameworks.

This library is not necessary nor recommended when targeting versions of .NET that include the relevant support.

Using Range with Arrays

The C# compiler needs the RuntimeHelpers.GetSubArray<T> method to be available to create subranges from arrays. This method is only available in netstandard2.1 and .NET Core 3.0, so creating subranges from arrays will fail to compile in .NET Framework.

Use Span<T>

A workaround is to add a reference to System.Memory and use Span<T>. Not only does this compile, it's much more efficient as it doesn't create a new array and copy the sliced data to it:

int[] array = new[] { 1, 2, 3, 4, 5, 6 };

// don't do this:
// var slice = array[1..^1];

// do this:
var slice = array.AsSpan()[1..^1];

Define GetSubArray<T>

The other fix is to define the necessary method in your source code. Copy the following code into your project:

https://gist.github.com/bgrainger/fb2c18659c2cdfce494c82a8c4803360

That type is not in this NuGet package so that the C# compiler doesn't warn that The predefined type 'RuntimeHelpers' is defined in multiple assemblies.

Showing the top 20 packages that depend on IndexRange.

Packages Downloads
WTelegramClient
Telegram Client API library written 100% in C# and .NET Standard | Latest MTProto & API layer version
14
WTelegramClient
Telegram Client API library written 100% in C# and .NET Standard | Latest MTProto & API layer version
13
WTelegramClient
Telegram client library written 100% in C# and .NET Standard
12
WTelegramClient
Telegram client library written 100% in C# and .NET Standard | Latest MTProto & API layer version
12
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 221 Release Notes: Update to Telegram API layer 221 - New objects (InputMediaStakeDice, Messages_EmojiGameOutcome, Messages_EmojiGameInfo, UpdateEmojiGameInfo, InputPasskeyCredentialFirebasePNV) - New methods (messages.getEmojiGameInfo, messages.summarizeText). - Updated Message flags and MessageMediaDice fields.
12
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 222 Release Notes: Making method Invoke virtual for library add-ons.
12
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 223 Release Notes: Update to Telegram API layer 223 - New types (e.g., MessageActionNoForwardsToggle, UpdateChatParticipantRank, MessageEntityFormattedDate) - New methods (e.g., Messages_EditChatCreator, Messages_EditChatParticipantRank). - Enhanced URL auth and admin methods with new parameters and flags. - Refactored keyboard button and MediaArea types for improved inheritance. Html/Markdown conversions: - Support for MessageEntityFormattedDate - Removed premium optional arg (always true now) - Stopped supporting non-standard markdown "emoji?id=". Correct syntax is "tg://emoji?id="
12
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 225 Release Notes: UpdateManager: Fix repeated RecoverGaps
12
WTelegramClient
Telegram client library written 100% in C# and .NET Standard
11
WTelegramClient
Telegram Client API library written 100% in C# and .NET Standard | Latest MTProto & API layer version
11
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 176 Release Notes: CollectUsersChats update user/chat fields from min info
11
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 222 Release Notes: - Update to Telegram API layer 222: gift crafting, keyboard buttons style, getFutureCreatorAfterLeave and more... - Making method Invoke virtual for library add-ons. - attribute TLDef.inheritBefore => inheritAt
11
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 222 Release Notes: Update to Telegram API layer 222: gift crafting, keyboard buttons style, getFutureCreatorAfterLeave and more...
11
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 222 Release Notes: api doc
11

* Update Microsoft.Bcl.Memory to 9.0.14 for CVE-2026-26127.

.NET Framework 3.5

.NET Framework 4.5

.NET Framework 4.6.2

.NET Framework 4.7

UAP 10.0.10240

.NET Standard 2.0

.NET Standard 2.1

Version Downloads Last updated
1.1.1 16 03/28/2026
1.1.0 5 12/17/2025
1.0.3 3 12/17/2025
1.0.2 3 12/17/2025
1.0.1 2 12/17/2025
1.0.0 9 12/17/2025