如何在 F# 交互中使用 Span?
How to use Span in F# interactive?
我尝试通过
添加对System.Memory
的引用
#r "C:/Program Files/dotnet/shared/Microsoft.NETCore.App/2.1.5/System.Memory.dll"
但 F# interactive 仍然显示 The value or constructor 'Span' is not defined
。当我尝试使用 open System.Memory
时,它显示 The namespace 'Memory' is not defined
。有办法吗?
您不需要 open System.Memory
,但您确实需要 open System
。您可能还想先将 System.Memory nuget 到 .NET 框架应用程序中,然后再引用它。我想知道 FSI 将如何与 Span<T>
交互。
#if INTERACTIVE
#r @"C:\Users\username\Documents\Source\ConsoleApplication1\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll"
#r "System.Runtime.dll"
#endif
open System
open System.Runtime.CompilerServices
[<IsByRefLike; Struct>]
type S(count1: Span<int>, count2: Span<int>) =
member x.Count1 = count1
member x.Count2 = count2
我尝试通过
添加对System.Memory
的引用
#r "C:/Program Files/dotnet/shared/Microsoft.NETCore.App/2.1.5/System.Memory.dll"
但 F# interactive 仍然显示 The value or constructor 'Span' is not defined
。当我尝试使用 open System.Memory
时,它显示 The namespace 'Memory' is not defined
。有办法吗?
您不需要 open System.Memory
,但您确实需要 open System
。您可能还想先将 System.Memory nuget 到 .NET 框架应用程序中,然后再引用它。我想知道 FSI 将如何与 Span<T>
交互。
#if INTERACTIVE
#r @"C:\Users\username\Documents\Source\ConsoleApplication1\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll"
#r "System.Runtime.dll"
#endif
open System
open System.Runtime.CompilerServices
[<IsByRefLike; Struct>]
type S(count1: Span<int>, count2: Span<int>) =
member x.Count1 = count1
member x.Count2 = count2