C
C#3y 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 User3y ago
Message Not Public
Sign In & Join Server To View
TheBoxyBear
TheBoxyBear3y 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
casogOP3y ago
Thanks
Accord
Accord3y 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.
Want results from more Discord servers?
Add your server