>>>>>>>> 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 ?
public static IEnumerable<TResult> OfType<TResult>(this IEnumerable source) { if (source == null) throw Error.ArgumentNull("source"); return OfTypeIterator<TResult>(source); } static IEnumerable<TResult> OfTypeIterator<TResult>(IEnumerable source) { foreach (object obj in source) { if (obj is TResult) yield return (TResult)obj; } }Just nit-picking... :-}