This works just fine:
protected void txtTest_Load(object sender, EventArgs e) { if (sender is TextBox) {...} }
Is ther
If you use inheritance like:
public class BaseClass {} public class Foo : BaseClass {} public class Bar : BaseClass {}
... Null resistant
if (obj?.GetType().BaseType != typeof(Bar)) { // ... }
or
if (!(sender is Foo)) { //... }