今天下了个VS2010的VPC版本,小玩了一把!很恐怖的,解压出来将近25G,里面什么Office,VS2008 SP1,TFS,Sharepoint,Sql Server2008应有尽有!唉,微软的速度太快了,程序员们都快跟不上了吧,现在估计还有好多人正在VS2005上写代码,都没有使用过VS2008!
VS2008给我的第一感觉就是界面比以前的版本都要好看,感觉应该是使用了WPF技术了,废话少说了先上代码了!
Code
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5
6 using Excel = Microsoft.Office.Interop.Excel;//引用COM组件
7 using System.Diagnostics;
8 namespace Demo01
9 {
10 class Program
11 {
12 static void Main(string[] args)
13 {
14 //Dynamic sytax,可以在runtime时赋值,获知参数类型,和VS2008的var差不多
15 dynamic num1 = 5;
16 dynamic str1 = "Hello World";
17 Console.WriteLine(num1);
18 Console.WriteLine(str1);
19
20 //Test optional arguments
21 TestOptionalMethod();//使用方法默认的参数值
22 TestOptionalMethod(5, 10, "IBM");//三个参数全部重新赋值
23 TestOptionalMethod(j: 5);//指定一个参数j
24
25 //Excel
26 var excel = new Excel.Application();
27 excel.Visible = true;
28 excel.Workbooks.Add();
29 excel.Cells[1, 1].Value = "Process Name";
30 excel.Cells[1, 2].Value = "Memory Usage";
31 var process = Process.GetProcesses()
32 .OrderBy(p => p.WorkingSet64)//此处有新的改进可以参照下面的图片
33 .Take(20);
34
35 int i = 2;
36 foreach (var p in process)
37 {
38 excel.Cells[i, 1].Value = p.ProcessName;
39 excel.Cells[i, 2].Value = p.WorkingSet64;
40 i++;
41 }
42
43 //excel.Cells[1, 1] = "ID";
44 //excel.Cells[1, 2] = "Number";
45 //int ii = 2;
46 //for (int j = 1; j < 5; j++)
47 //{
48 // excel.Cells[ii, 1].Value = j;
49 // excel.Cells[ii, 2].Value = j * 2;
50 // ii++;
51 //}
52 }
53 static void TestOptionalMethod(int i = 1, int j = 2, string name = "Microsoft")
54 {
55 Console.WriteLine("The first number is :" + i);
56 Console.WriteLine("The second number is :" + j);
57 Console.WriteLine("The company name is :" + name);
58 }
59 }
60 }
61