title: How do I determine if a class member exists?
body: <p>I have a public subroutine that is called by many classes. However, I now need to do something in that subroutine that only pertains to a small number of the classes that call it. So instead of going back and adding the property to all of the existing classes, I would like to simply check to see see if that class has that property and if so, then do something with it. But I can't seem to figure out how to simply check for the existence of the member without getting an error.</p>
  
  <p>For example:</p>
  
  <pre><code>Public Class_1
  
       Public a1 as string = ""
  
     Public Sub New()
         ' when a button is clicked call subroutine "check()"
     End Sub
  
  End Class
  
  Public Class_2
  
       Public a1 as string = ""
       Public a2 as integer = 0
  
     Public Sub New()
         ' when a button is clicked call subroutine "check()"
     End Sub
  
  End Class
  
  Public Class whatever
  
      Public Sub check(sender as object)
         If sender.a2 = 0 then
         ' do something
         End if
      End Sub
  
  End Class
  </code></pre>
  
  <p>I have tried such things as</p>
  
  <pre><code>If not(sender.a2 is nothing) then
  If isnothing(sender.a2) then
  </code></pre>
  
  <p>But I can't get past the fact that I get an error simply by using "sender.a2" since a2 is not always a member of the sender.</p>
  
  <p>How can I check to see if a2 is a member of the sending class without using "sender.a2"?</p>