这根本与 Windows 窗体无关,它仅用于“背景”。
AddRange
当我在MenuStrip.Items
要求强制ToolStripMenuItem
转换时遇到错误时,我正在玩弄 Windows 窗体ToolStripItem
但我已经有一个AddRange
for aForm.Controls
之前不需要演员表。
经过一些实验,我设法发现当有多个重载时会发生错误,AddRange
所以我试图验证我的想法:
type Foo () = class end
type Bar () = inherit Foo ()
type FooCollection () = class end // not really necessary
type Test1 () =
member __.AddRange (col: FooCollection) = () // could be an int or anything instead
member __.AddRange (foos: Foo []) = ()
type Test2 () = member __.AddRange (foos: Foo []) = ()
let lst1, lst2 = Test1 (), Test2 ()
lst1.AddRange [|Bar ()|] // error: have to explicitely cast => [|Bar () :> Foo|]
lst2.AddRange [|Bar ()|] // works
问题就是为什么;从我的角度来看,这个电话并不模棱两可