简体   繁体   English

F#LazyList-> IList

[英]F# LazyList -> IList

I'm creating a module that will be used by C# code, so I would rather not return the LazyList<> directly. 我正在创建一个将由C#代码使用的模块,因此我宁愿不直接返回LazyList<> If I did, the C# would have to reference the FSharp.PowerPack , which seems strange. 如果这样做的话,C#必须引用FSharp.PowerPack ,这似乎很奇怪。

So I would rather return a IList<> , but when I try to do something like: 所以我宁愿返回一个IList<> ,但是当我尝试做类似的事情时:

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

However, this gives me the error: 但是,这给了我错误:

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

This leads me to believe that LazyList<> does NOT implement IList<> . 这使我相信LazyList<>implement IList<> Is this true? 这是真的?

What am I missing? 我想念什么?

It is true, LazyList does not implement the IList interface. 的确,LazyList没有实现IList接口。 It implements IEnumerable though. 它实现了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