这个很好用:
protected void txtTest_Load(object sender, EventArgs e)
{
if (sender is TextBox) {...}
}
有没有办法检查发送者是否不是TextBox,某种等同于!=表示" Is“的东西?
请不要建议将逻辑移到ELSE{} :)
发布于 2009-02-09 21:06:06
这是一种方法:
if (!(sender is TextBox)) {...}
发布于 2020-11-25 16:44:28
发布于 2009-02-09 21:09:02
你不能用更冗长的“老”方法,在is
关键字之前:
if (sender.GetType() != typeof(TextBox)) { // ... }
https://stackoverflow.com/questions/529944
复制相似问题