在UserControl中找不到"类型或命名空间名称"

saa*_*aam 1 c# user-controls controls

我想在UserControl中执行以下操作:

foreach(Control c in this.Controls)
{
   if(c is CheckBox)
   {
       // Do stuff here
   }
}
Run Code Online (Sandbox Code Playgroud)

但是我得到了错误:

错误1找不到类型或命名空间名称'Control'(您是否缺少using指令或程序集引用?)
错误2找不到类型或命名空间名称'CheckBox'(您是否缺少using指令或装配参考?)

谢谢你的指导.

And*_*rei 8

您忘了在指令中包含System.Web.UI.WebControlsSystem.Windows.Forms(根据您正在开发的应用程序的类型)using.