All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
关于xml编码问题在VB,PHP,JAVA下的解决方案_[XML教程]
了解ASP2.0向其它网页传递信息的方法_.net资料_编程技术
Sql,server表面区域配置工具保服务_[SQL,Server教程]
计算两者相差几个月零几天_[PHP教程]
ASP.NET从零起步设计网站全过程(2)_[Asp.Net教程]
visual c++中的画笔类CPen使用实例
了解PHP处理复杂数学问题的10个PEAR类_php资料_编程技术
javascript应用实例:点出统计器_JavaScript技术_编程技术
PHP编程52个经典小技巧_[PHP教程]
Asp.net数据库操作类,c#_[Asp.Net教程]
Reading number is top 10 pictures
漂亮的跳舞妹妹2
2012 national geographic daily picture8
A man's favorite things9
9.3阅兵全景图6-常规导弹梯队和核导弹梯队
移民小国也实惠1
Men don't mature ten sign
The money of more than 100 countries and regions3
Azusa Yamamoto2
Absolutely shocked. National geographic 50 animal photographys10
The money of more than 100 countries and regions1
Download software ranking
传奇私服架设教程
VC++6.0简体中文版
Unix video tutorial19
Tram sex maniac 2 (H) rar bag3
Popkart Cracked versions Mobile phone games
Boxer Classic video3
Unix video tutorial13
双旗镇刀客B
Jinling thirteen stock
Ashlynn Video3
delv published in(发表于) 2014/1/6 9:05:41 Edit(编辑)
C#,3.0新特性初步研究,Part5:匿名类型_[Asp.Net教程]

C#,3.0新特性初步研究,Part5:匿名类型_[Asp.Net教程]

C# 3.0新特性初步研究 Part5:匿名类型_[Asp.Net教程]

匿名类型(Anonymouse Type)——这年头什么多系都匿名了 : )
在初始化的时候根据初始化列表自动产生类型的一种机制。


典型的代码:
1class Program
2 {
3 static void Main(string[] args)
4 {
5 var x = new { a = 3, b = 5, c = "some text" };
6 Console.WriteLine(x.a.ToString());
7 }
8 }很奇怪吧~~~
不要认为这个var x真的是没有类型,其实这又是一个编译器的魔术,
当我们编译这段代码的时候,编译器会自动产生以下类型定义:
1class __Anonymous1
2{
3 private int _a = 3;
4 private int _b = 5;
5 private string _c = “some text”;
6
7 public int a { get { return _a; } set { _a = value; } }
8 public int b { get { return _b; } set { _b = value; } }
9 public int c { get { return _c; } set { _c = value; } }
10}
11
这样就不会和我前面所的var必须初始化,并且必须让编译器“猜得出”正确的类型这一句话产生矛盾。
PS:再过20年估计编译器就什么都可以做了,还是行业专家,“老板,买一个针对电信行业的编译器,要带SP增值服务扩张包的”


来源:网络







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.