❔ where generic is itypea or itypeb
Is there syntax to check weather a generic attribute is either of two interface types?
Pseudo:
Where T : ITypeA or ITypeB
4 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
You can compare the type of a generic at runtime with
typeof(T)
. Compile-time constraints however are only additive. If you want to enforce it at compile-time, you need a common backing interface for both
That would also defeat the purpose of constraints in allowing referencing type and interface members from a generic instance.Thanks
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.