C# 2.0 New Feature(1)
今天下载并安装了visual stdio 2005 for team for develop for ..............^_^
赶快装一下,不错
我要传整屏,有限制,只能翻过来传上
再装msdn,
后发现sql server 2005 expess 太弱了,下了一个 正式版 for developer
1. new feature
有了一个很贴心 的特性
自定义可以被 foreach 的类
引用一下msdn的源程序了
1
//继承System.Collections.IEnumerable
2
public class dayWeeks : System.Collections.IEnumerable
3
{
4
//定义一个string[]
5
string[] dayWeek = { "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat" };
6
//重载GetEnumerator()
7
public System.Collections.IEnumerator GetEnumerator()
8
{
9
for (int i = 0; i < dayWeek.Length; i++)
10
{
11
//yield return 呵呵,^_^,专用于 iterator block
12
yield return dayWeek[i];
13
}
14
}
15
}
16
static void Main(string[] args)
17
{
18
new Program().printer("this is my vs 2005");
19![](/Images/OutliningIndicators/InBlock.gif)
20![](/Images/OutliningIndicators/InBlock.gif)
21
// Declare a list of type int
22
GenericList<int> list1 = new GenericList<int>();
23![](/Images/OutliningIndicators/InBlock.gif)
24
// Declare a list of type string
25
GenericList<string> list2 = new GenericList<string>();
26![](/Images/OutliningIndicators/InBlock.gif)
27
// Declare a list of type ExampleClass
28
GenericList<ExampleClass> list3 = new GenericList<ExampleClass>();
29
30![](/Images/OutliningIndicators/InBlock.gif)
31
//好了定义一个对象
32
dayWeeks dayWeeks = new dayWeeks();
33
//go ahead foreach![](/Images/dot.gif)
![](/Images/dot.gif)
![](/Images/dot.gif)
![](/Images/dot.gif)
.
34
foreach (string j in dayWeeks)
35
{
36
System.Console.WriteLine(j);
37
}
38![](/Images/OutliningIndicators/InBlock.gif)
39
40
}
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
4
![](/Images/OutliningIndicators/InBlock.gif)
5
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
6
![](/Images/OutliningIndicators/InBlock.gif)
7
![](/Images/OutliningIndicators/InBlock.gif)
8
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
9
![](/Images/OutliningIndicators/InBlock.gif)
10
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
14
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
15
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
16
![](/Images/OutliningIndicators/None.gif)
17
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/InBlock.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/dot.gif)
![](/Images/dot.gif)
![](/Images/dot.gif)
![](/Images/dot.gif)
![](/Images/dot.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
36
![](/Images/OutliningIndicators/InBlock.gif)
37
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)