如何循环控制并否定某个工具

Pla*_*Pro 0 c# controls

我想循环我的控件并进行IF条件化,但改为使用:

foreach(Control c in this.Controls)
    {
      if(c is TextBox) {}
    }
Run Code Online (Sandbox Code Playgroud)

我想做点什么:

if(!c is TextBox){}
Run Code Online (Sandbox Code Playgroud)

你懂 ?只有当控件CDIFFERENTTextBox时我才想进入循环.当然,我尝试的方法!不起作用Controls.我怎么能否认呢?

And*_*rei 6

只需在括号中包含条件:

if (!(c is TextBox)) {}
Run Code Online (Sandbox Code Playgroud)