首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

匿名部类的创建和使用

2013-03-13 
匿名类型的创建和使用using Systemusing System.Collections.Genericusing System.Linqusing System.Te

匿名类型的创建和使用

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);        }    }}

匿名部类的创建和使用

输出

匿名部类的创建和使用
 

热点排行