>>>>>> foreach (Control c in parentForm.Controls) >>>>>> { >>>>>> if (c is TextBox) >>>>>> { >>>>>> >>>>>> } >>>>>> } >>>>>>>>>>>
>>>>>var c as TextBox >>>>> >>>>>if (c!=null) >>>>> { >>>>> >>>>> }>>>>>
>>>> >>>> foreach (Control c in parentForm.Controls) >>>> { >>>> if (c is TextBox) >>>> { >>>> TextBox tb = c as TextBox; >>>> tb.CharacterCasing = CharacterCasing.Upper; >>>> } >>>> } >>>>A Linq way:
foreach (Control c in parentForm.Controls.Where(x=>x is TextBox)) >>> { >>> ((TextBox)c).CharacterCasing = CharacterCasing.Upper; >>> }>>
>>((TextBox)c).CharacterCasing = CharacterCasing.Upper; >>>>The one I used worked but I prefer this one and I substituted it.
foreach (TextBox c in parentForm.Controls.OfType< TextBox>()) > { > c.CharacterCasing = CharacterCasing.Upper; > }Good. I'd forgotten about OfType(). Don't know if it's any faster because, internally, I think it does a 'is X' anyway ?