匿名对象集合

来源:互联网 发布:r语言绘制矩阵散点图 编辑:程序博客网 时间:2024/05/20 04:28
//匿​名​对象
        var list = new List<object>();

        list.Add(new {BranchName = "A01", Address = "人民路108号", Tel = "66666666"});
        list.Add(new {BranchName = "A02", Address = "天津路888号", Tel = "88888888"});
   
        var result = new { title = '分店地址' list = list};

//非匿​名​对象
        class Branch
        {
            public string BranchName { get; set; }
            public string Address { get; set; }
            public string Tel { get; set; }
        }

        List<Branch> list = new List<Branch>();

        list.Add(new Branch() {BranchName = "A01", Address = "人民路108号", Tel = "66666666"});       
        list.Add(new Branch() {BranchName = "A02", Address = "天津路888号", Tel = "88888888"});       

        var result = new { title = '分店地址' list = list};

0 0