代码之家  ›  专栏  ›  技术社区  ›  ozgur

如何在F#interactive中使用Span?

  •  3
  • ozgur  · 技术社区  · 8 年前

    System.Memory 通过

    #r "C:/Program Files/dotnet/shared/Microsoft.NETCore.App/2.1.5/System.Memory.dll"
    

    The value or constructor 'Span' is not defined . 当我试着用open 上面写着 The namespace 'Memory' is not defined

    1 回复  |  直到 8 年前
        1
  •  3
  •   s952163    8 年前

    你不需要这么做 open System.Memory open System . 您可能还希望先将System.Memory添加到.NET framework应用程序中,然后引用它。我想知道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  
    
    推荐文章