2

我正在创建一个将由 C# 代码使用的模块,所以我宁愿不LazyList<>直接返回。如果我这样做了,C# 将不得不引用FSharp.PowerPack,这看起来很奇怪。

所以我宁愿返回 a 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<>。这是真的?

我错过了什么?

4

1 回答 1

4

确实,LazyList 没有实现 IList 接口。它虽然实现了 IEnumerable。

[<Sealed>]
type LazyList<'T> =
   interface IEnumerable<'T>
   interface System.Collections.IEnumerable
于 2013-10-28T15:37:34.823 回答