I am having a casting issue with MdiChildren.
This works:
MyForm mf = (MyForm)this.ActiveMdiChild;
this does not work:
MyForm[] mfs = (MyForm[])this.MdiChildren;
All forms in the parent form are instances of MyForm, But I cannot successfully cast them. This means that I cannot use any of the methods that MyForm provides because they are only Form objects. What can I do to rectify this issue?
The MdiChildren property returns an array of
Forminstances, which is not the same thing as (and is not directly convertible to) an array ofMyForminstances.You can use LINQ’s Cast() method to perform an explicit conversion: