0

What do you think about casting or converting using as? For example, should I use this one?

 CheckBox cbStatus = sender as CheckBox ;

Or this one?

 CheckBox cbStatus = (CheckBox)sender;
cagin
  • 5,772
  • 14
  • 74
  • 130

1 Answers1

1

If you do “as”, then always check for null. If you are sure of the type which is returned, then simply cast it instead of doing “as”. “As” can return null

Abhishek Jain
  • 2,597
  • 1
  • 18
  • 12