try foreach(Control c in this.Controls)
{
if(c.GetType().ToString() == "System.Windows.Forms.TextBox")
{
((TextBox)c).Text = "aaa";
}
}

解决方案 »

  1.   

    Evaluates to a type that implements IEnumerable or a type that declares a GetEnumerator method. In the latter case, GetEnumerator should either return a type that implements IEnumerator or declares all the methods defined in IEnumerator
      

  2.   

    using System;public class ParseTest {
        [FlagsAttribute]
        enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };    public static void Main() {        Console.WriteLine("The entries of the Colors Enum are:");
            foreach(string s in Enum.GetNames(typeof(Colors)))
                Console.WriteLine(s);        Console.WriteLine();        Colors myOrange = (Colors)Enum.Parse(typeof(Colors), "Red, Yellow");
            Console.WriteLine("The myOrange value has the combined entries of {0}", myOrange);
        }
    }
      

  3.   

    foreach (type identifier in expression) statement
    expression 
    对象集合或数组表达式。集合元素的类型必须可以转换为 identifier 类型。请不要使用计算为 null 的表达式。 
    而应计算为实现 IEnumerable 的类型或声明 GetEnumerator 方法的类型。在后一种情况中,GetEnumerator 应该要么返回实现 IEnumerator 的类型,要么声明 IEnumerator 中定义的所有方法。