如何将弱类型ICollection转换为F#List
本文关键字:转换 F#List ICollection 类型 | 更新日期: 2023-09-27 18:21:33
我有一个ICollection,需要将其转换为F#List。如果集合是强类型的,即ICollection<'T> ,很明显,我可以写:
let myList = List.ofSeq myCollection
但是我该如何处理弱类型集合呢?
let somecoll = ... // Assuming somecoll is ICollection of something
let whatever = somecoll
|> Seq.cast // Getting F# Seq
|> List.ofSeq // or Array.ofSeq