C
C#2y ago
casog

❔ 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
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
TheBoxyBear
TheBoxyBear2y ago
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.
casog
casog2y ago
Thanks
Accord
Accord2y ago
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.