The type arguments for method cannot be inferred from the usage

前端 未结 6 1718
盖世英雄少女心
盖世英雄少女心 2020-12-05 04:16

Maybe I\'m overworked, but this isn\'t compiling (CS0411). Why?

interface ISignatur
{
    Type Type { get; }
}

interface IAccess where          


        
6条回答
  •  死守一世寂寞
    2020-12-05 04:28

    Get takes two type arguments. When you call service.Get(new Signatur()); how does the compiler know what T is? You'll have to pass it explicitly or change something else about your type hierarchies. Passing it explicitly would look like:

    service.Get(new Signatur());
    

提交回复
热议问题