I’m trying to avoid using a long else if statement.
Lets say I have an object and I want to test if it’s of type ClassA, ClassB, ClassC, etc..?
What is a clean way of doing this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Something like..
?
And obviously if you have a lot of types and are seeing bad performance, then throw it into a dictionary and use ContainsKey.