匿名类型的创建和使用
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { var stu = new { id = 12, name = "halon", age = 22, address = "深圳", MZ = new {id=3,name="汉族"} }; Console.WriteLine("编号:{0},姓名:{1},年龄:{2},地址:{3},民族:{4}",stu.id,stu.name,stu.age,stu.address,stu.MZ.name); } }}
输出