How do I specify multiple generic type constraints on a single method?

前端 未结 4 546
傲寒
傲寒 2021-01-07 16:09

I can restrict generics to a specify type using the \"Where\" clause such as:

public void foo() where TTypeA : class, A

How d

相关标签:
4条回答
  • 2021-01-07 16:43
    public void foo<TTypeA, TTypeB>() where TTypeA : class, A where TTypeB : class, B
    

    dang, 20s late. Vote for James Curran, he was first.

    0 讨论(0)
  • 2021-01-07 16:56
     public void foo<TTypeA, TTypeB>() where TTypeA : class, A 
                                       where TTypeB : class, B 
    
    0 讨论(0)
  • 2021-01-07 16:59

    just replace && with another where

    0 讨论(0)
  • 2021-01-07 17:04

    Something like this?

     public void foo<TTypeA, TTypeB>() where TTypeA : class where TTypeB : class
    
    0 讨论(0)
提交回复
热议问题