小编Ben*_*Ben的帖子

无法从用法中推断出方法的类型参数

也许我工作过度,但这不是编译(CS0411).为什么?

interface ISignatur<T>
{
    Type Type { get; }
}

interface IAccess<S, T> where S : ISignatur<T>
{
    S Signature { get; }    
    T Value { get; set; }
}

class Signatur : ISignatur<bool>
{
    public Type Type
    {
        get { return typeof(bool); }
    }
}

class ServiceGate
{
    public IAccess<S, T> Get<S, T>(S sig) where S : ISignatur<T>
    {
        throw new NotImplementedException();
    }
}

static class Test
{
    static void Main()
    {
        ServiceGate service = new ServiceGate();
        var access …
Run Code Online (Sandbox Code Playgroud)

c# type-inference

50
推荐指数
2
解决办法
11万
查看次数

标签 统计

c# ×1

type-inference ×1