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
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
1
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: add accessible properties to IAlbumInputMedia & IInputRichMedia
1
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: Bot API 10.0 https://core.telegram.org/bots/api#may-8-2026
1
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: - Bot API 9.0b (CanDeleteSentMessages) - Added ChatMemberRestricted.IsMuted helper
2
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: - Bot API 9.1 (https://core.telegram.org/bots/api#july-3-2025) - ReplyParameters(Message) supports null - Fix MessageLink() for non-topics group - TransferGift: fix type for newOwnerChatId - Sealed some internal types for performance - faster IsServiceMessage
2
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: Fix netstandard2.0 package build
1
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: Fix type for MessageEntity.UnixTime
1
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: GetInfoAndDownloadFile now accept File ID or directly a FileBase (video, audio, document, sticker, etc...)
1
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: Implicit conversion from List<> and List<List<>> to reply markup
5
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: implicit InputFile(string) InputFileId(string) now allows null string (and return null)
2
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: InputRichMessage implicit conversion from HTML string, using HtmlText.ToInputRichMessage (supports tg://__?file_id= syntax)
2
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: mark RichMessageButton.Text as required
2
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: Polling: Clarify methods descriptions. Removed IUpdateReceiver/DefaultUpdateReceiver (loop code moved directly into Polling) Obsoleted AsyncEnumerableReceivers
2
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: Removed AsyncEnumerableReceivers
1
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: Removed library dependency on AspNetCore framework. Moved method ConfigureTelegramBotMvc to package Telegram.Bot.AspNetCore.
1
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: Removed Obsolete *Async methods
2
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: SendHtml returns the number of sent messages in field msg.MigrateToChatId
10
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: SendHtml supports receiverUserId
1
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: SendHtml supports src="tg://...?file_id=..." syntax
2
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. Release Notes: Support MessageEntity.UnixTime in ToHtml/ToMarkdown
1

  • 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 4 09/18/2026
1.1.0 2 09/18/2026
1.0.3 1 09/20/2026
1.0.2 1 09/20/2026
1.0.1 1 09/20/2026
1.0.0 1 09/20/2026