By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,041 Members | 1,858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,041 IT Pros & Developers. It's quick & easy.

Is a given Type Me or one of my base classes?

P: 1
Expand|Select|Wrap|Line Numbers
  1. Public Class ClassA  End Class
  2. Public Class ClassB 
  3. Inherits ClassA      
  4. Public Function IsInMyLine(aType As Type) As Boolean
  5. ' What do I do?
  6. ' If I had a data type, I could say: TryCast(Me,datatype)'
  7. '  but I have a Type instead.
  8. End Function
  9. End Class
  10. Public Class ClassC  End Class
  11. Public Class ClassD
  12. Inherits ClassC      End Class
  14. Dim classB As new ClassB
  15. classB.IsInMyLine(ClassD.GetType)  ' should be false
  16. classB.IsInMyLine(ClassA.GetType)  ' should be true
Jun 15 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.