检查对象的类型是不是 - C#(=相当于" IS&QUOT!) [英] Check if object is NOT of type (!= equivalent for "IS") - C#
本文介绍了检查对象的类型是不是 - C#(=相当于" IS&QUOT!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这只是正常工作:
protected void txtTest_Load(object sender, EventArgs e)
{
if (sender is TextBox) {...}
}
有没有一种方法来检查,如果发件人不是一个TextBox,某种!等效的=为是?
Is there a way to check if sender is NOT a TextBox, some kind of an equivalent of != for "is"?
请,不建议移动逻辑ELSE {}:)
Please, don't suggest moving the logic to ELSE{} :)
推荐答案
这是一个方法:
if (!(sender is TextBox)) {...}
这篇关于检查对象的类型是不是 - C#(=相当于" IS&QUOT!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文