Thursday, January 17, 2013

typeof Reflection comparisons in C#

Compare an instance to a type!

  1. if (foo.GetType() == typeof(HiddenField)) {
  2. if (foo.GetType().FullName == typeof(HiddenField).FullName) {

No comments:

Post a Comment