How to check if a type is a TypeBuilder or contains a TypeBuilder generic parameter #93330
-
How to check if a type is a TypeBuilder or contains a TypeBuilder generic parameter |
Beta Was this translation helpful? Give feedback.
Answered by
KennethHoff
Oct 12, 2023
Replies: 2 comments 3 replies
-
var isTypeBuilder = x is TypeBuilder || x.GetType().GetGenericArguments().Any(a => a is TypeBuilder); Does this work? If not, I don't think it's too far off - assuming I understood the question correctly. |
Beta Was this translation helpful? Give feedback.
3 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the
is
pattern supports just mentioning the Type. I'm not too knowledgable about Reflection - hadn't even heard aboutTypeBuilder
before this post.You could recursively look through the
GetType().GetGenericArguments()
lists and then do something if any of them are whatever you need.