显示列表

类级



private void button1_Click(object sender, EventArgs e)
{
    Filler<Info> filer = new Filler<Info>();
    Info info = new Info();
    info.Name = "A";
    filer.Add(info);
}


public class Filler<T>
{
    IList<T> list = new List<T>();

    public void Add(T t)
    {
        list.Add(t);
    }
}

public class Info
{
    private string name = "";
        
    public string Name { get { return name; } set { name = value; } }
}





方法级


private void button1_Click(object sender, EventArgs e)
{
    Filler filer = new Filler();
    Info info = new Info();
    info.Name = "A";
    filer.Add<Info>(info);
}

public class Filler
{
    ArrayList list = new ArrayList();

    public void Add<T>(T t)
    {
        list.Add(t);
    }
}

public class Info
{
    private string name = "";
        
    public string Name { get { return name; } set { name = value; } }
}



 

标签:未完待续 
返回摘要 | 分类(C#/CSharp) | 访问(294) | 编辑