This should be Really Simple but ... I'm using C# 4.0. I want to copy Application.OpenForms to an array without writing my own loop.
Application.OpenForms is of type System.Windows.Forms.FormC
ollection.
This type does not have a CopyTo method, but
http://msdn.microsoft.com/en-us/library/system.windows.forms.formcollection.aspx says that ICollection.CopyTo is an explicit interface implementation. I don't see how to go about using that.
If you look carefully, there is not hyperlink from the ICollection.CopyTo method. Only an indication that it is inherited from ReadOnlyCollectionBase. If you follow that lead, you see that the method is Private. That means that is it only used internally by ReadOnlyCollectionBase and cannot be used. When you see a list of methods under a heading of Explicit Interface Implementations, it is an indication for programmers who would want to inherit from the class, not things that you can use from an instance of the class.
Since Microsoft has not built a Copy method into the class, you have no choice, you need to loop. What is wrong with that? It requires only 3 lines of code.