📜  c# 存储没有参数的泛型类型 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:02.610000             🧑  作者: Mango

代码示例1
public interface IModel where T : class
{
    T Value { get; }
}

public class Model : IModel where T : class
{
    public T Value { get; set; }
}


class Program
{
    static void Main(string[] args)
    {
        var foo = new Model()
        {
            Value = "hello world",
        };

        IModel boo = foo;

        Console.WriteLine(boo.Value);
    }
}