Two well-known ways to do this:
1) Using the IS operator:
if (!(sender is TextBox)) {...}
2) Using an AS-operator (useful if you also need to work with an instance of textBox):
var textBox = sender as TextBox; if (sender == null) {...}
John-Philip Jul 27 '17 at 17:56 on 2017-07-27 17:56
source share