roman m roman m - 1 year ago 96
ASP.NET (C#) Question

Check if object is NOT of type (!= equivalent for "IS") - C#

This works just fine:

protected void txtTest_Load(object sender, EventArgs e)
if (sender is TextBox) {...}


Is there a way to check if sender is NOT a TextBox, some kind of an equivalent of != for "is"?

Please, don't suggest moving the logic to ELSE{} :)

Answer Source

This is one way:

if (!(sender is TextBox)) {...}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download