簡體   English   中英

F#LazyList-> IList

[英]F# LazyList -> IList

我正在創建一個將由C#代碼使用的模塊,因此我寧願不直接返回LazyList<> 如果這樣做的話,C#必須引用FSharp.PowerPack ,這似乎很奇怪。

所以我寧願返回一個IList<> ,但是當我嘗試做類似的事情時:

let x = LazyList.ofSeq {0..10}
let y = x :> IList<int32>

但是,這給了我錯誤:

The type 'LazyList<int> is not compatible with the type 'IList<int>'

這使我相信LazyList<>implement IList<> 這是真的?

我想念什么?

的確,LazyList沒有實現IList接口。 它實現了IEnumerable。

[<Sealed>]
type LazyList<'T> =
   interface IEnumerable<'T>
   interface System.Collections.IEnumerable

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM