IndexRange 1.0.3

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

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
Sripe.DataAcquisition
Introduction: This package provide the base classes and interfaces which could be used to build a new data acquiring program.
4
ijw.DataTransfer.MessagesCache.Memory
Package Description
2
ijw.DataTransfer.ClientApp
Package Description
2
ijw.DataTransfer.MessagesCacheFactory
Package Description
2
Sripe.DataAcquisition.MWD.PCDWD
提供定向数据采集的数据实体类与相关组件.
2
ijw.DataTransfer.Server
Introduction: This package includes data recieving classes which could be used to build server applications. What's in it: 1. SripeDataReceiver: working with SripeDataClient, in charges of data recieving and confirming. 2. SimpleDataReceiver: working with SimpleDataClent, in charges of data recieving.
2
Sripe.DataUnit
What's new: 0.4.4(2023.4.20): *fix bug: add Unit.Get for recently added unit. +L/s² 0.4.3(2023.4.20): *fix bug: duplilcated unit string m/h to h/m. 0.4.2(2023.4.19): *put "" in 1st place. 0.4.1(2023.4.19): +"" in GetAllUnitDesciption(). 0.4.0(2023.4.18): +new UnitMeterPerHour, unitHourPerMeter. 0.3.9(2023.4.13): +new Unit, to fit GetAllUnitDesciption(). 0.3.8(2023.4.13): +Unit.GetAllUnitDesciption. 0.3.7(2022.1.24): +net50 net60 support. 0.3.6(2021.4.7): +UnitNewton. +UnitCubicMeterPerMinute and UnitCubicMeterPerSecond. 0.3.4(2020.10.28): *fix UnitMMHO_SK namespace bug. 0.3.3(2020.10.20): +UnitMMHO_SK UnitMmhoPerCM 0.3.1(2020.10.15): What's new: 0.4.4(2023.4.20): *fix bug: duplilcated unit string m/h to h/m. 0.4.4(2023.4.20): *fix bug: duplilcated unit string m/h to h/m. 0.4.2(2023.4.19): *put "" in 1st place. 0.4.1(2023.4.19): +"" in GetAllUnitDesciption(). 0.4.0(2023.4.18): +new UnitMeterPerHour, unitHourPerMeter. 0.3.9(2023.4.13): +new Unit, to fit GetAllUnitDesciption(). 0.3.8(2023.4.13): +Unit.GetAllUnitDesciption. 0.3.7(2022.1.24): +net50 net60 support. 0.3.6(2021.4.7): +UnitNewton. +UnitCubicMeterPerMinute and UnitCubicMeterPerSecond. 0.3.4(2020.10.28): *fix UnitMMHO_SK namespace bug. 0.3.3(2020.10.20): +UnitMMHO_SK UnitMmhoPerCM 0.3.1(2020.10.15): +
2
Sripe.DataAcquisition.MudLog
提供录井数据采集的数据实体类、采集器、解析器与相关组件.
2
Sripe.DataAcquisition.WitsMessages
Package Description
2
NewLife.Core
核心基础组件,日志(文件/网络)、配置(XML/Json/Http)、缓存(内存/Redis)、网络(Tcp/Udp/Http)、RPC框架、序列化(Binary/XML/Json)、APM性能追踪。旧版请找2021.1225
2
ijw.DataTransfer.Client.Winform
Package Description
1
Sripe.DataAcquisition.Frac
Package Description
1
ijw.DataTransfer
This package includes the base classes and interfaces for Sripe data transfering. Normaly, you don't use it directly.
1
Sripe.DataAcquisition.WellTesting
Introduction: This package provide the base classes and interfaces which could be used to build welltesting data acquiring program. What's in it: 1. IRealtimeRecordAcquirer: Base interface of front-end data acquiring. Sripe.SiteApp uses it to acquire data. You should implement this interface according to the specific equipment model. 2. RealtimeRecordAcquiredEventArg: event argument class for new data acquired event.
1
ijw.DataTransfer.Client
What's in it: 1. ReliableTransferClient: working with ReliableDataReciever, to send/resend data. 2. SimpleDataClient: working with SimpleDataReceiver, to send data. 3. MultipleTargetsTransferClient: working with SimpleDataReceiver/ReliableDataReciever, multi-target data sending.
1
ijw.DataTransfer.MessagesCache.EF
Package Description
1
Sripe.DataAcquisition.Mud
Package Description
1
ijw.DataTransfer.MessagesCache.EF.SQLite
Package Description
1
ijw.DataTransfer.MessagesCache.EFCore
Package Description
1
ijw.DataTransfer.MessagesCache.EFCore.SQLite
Package Description
1

* Support uap10.0 target framework. * Use optimized Index.GetOffset in Range.GetOffsetAndLength.

.NET Framework 3.5

.NET Framework 4.5

.NET Framework 4.7

  • No dependencies.

UAP 10.0.10240

.NET Standard 2.0

  • No dependencies.

.NET Standard 2.1

  • No dependencies.

Version Downloads Last updated
1.0.3 2 2025/6/1
1.0.2 1 2025/4/17
1.0.1 0 2022/3/5
1.0.0 0 2019/10/4