Home generic interface type restricting another generic interface
Reply: 1

generic interface type restricting another generic interface

Luminous_Dev
1#
Luminous_Dev Published in 2018-02-13 10:39:15Z

How can I implement generic interface that restrict a type of interface that is generic?

interface A<T>

interface B<T> where T: class

I need the interface A<> to be restricted to interface B with any class type

I am thinking that it may look something like

interface A<T> where T : B<T>

or

interface A<B<T>> where T : class

but both doesnt seem to work

Any solution?

Henrik
2#
Henrik Reply to 2018-02-13 10:54:24Z

You're overengineering this. Simply do this:

interface A<T> where T : class
{
    B<T> SomeProperty { get;}
    void SomeMethod(B<T> param);
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.295853 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO