c# generics error: The constraints for type parameter 'T' of method …?

后端 未结 3 2218
别跟我提以往
别跟我提以往 2021-01-02 01:41

Getting the following error:

Error 1 The constraints for type parameter \'T\' of method
\'genericstuff.Models.MyClass.GetC

3条回答
  •  孤城傲影
    2021-01-02 02:11

    You need to constrain your interface, too.

    public interface IMyClass
    {
        int GetCount(string filter) where T : class;
    }
    

提交回复
热议问题