Home generic interface type restricting another generic interface
Reply: 0

generic interface type restricting another generic interface

user5866 Published in September 21, 2018, 8:04 am

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>


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

but both doesnt seem to work

Any solution?

share|improve this question
  • 1
    How does your first attempt "not work"? I'm not sure what exactly you are trying to achieve, but the first version misses the class constraint: interface A<T> where T : class, B<T> {} – René Vogt Feb 13 at 10:45
  • doesnt seem to work? In what way does it not work? Are you just missing the class constraint in A<T>? – DavidG Feb 13 at 10:45

1 Answer 1

active oldest votes
up vote 1 down vote accepted
You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO