Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想遍历我的控件并设置一个IF条件,而是使用这个:
IF
foreach(Control c in this.Controls) { if(c is TextBox) {} }
我想做类似的事情:
if(!c is TextBox){}
你知道 ?C只有当控件是文本框时,我才想进入循环DIFFERENT。当然,我尝试的方法!不适用于Controls. 我怎么能否认呢?
C
DIFFERENT
!
Controls
只需将条件包含在括号中:
if (!(c is TextBox)) {}
foreach(Control c in this.Controls) { if(!(c is TextBox)) { //do something } }