[csharp] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { www.2cto.com 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); } } } 輸出