试试看,创建一个简单的控制台应用程序:
1、选择File|New|Project...菜单项,创建一个新的控制台应用程序项目。
2、在所显示窗口的Project Types:窗格中选择Visual C#节点,在Temlpates:窗格中选择Console Application项目类型。当然你也可以自定义保存项目的路径。
3、单击OK按钮完成创建。
4、初始化项目后,在主窗口显示的文件里添加如下代码行:
1
using
System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace ConsoleApplication1
6 {
7 class Program
8 {
9 static void Main( string [] args)
10 {
11 // out text to the screen.
12 Console.WriteLine( " hello! " );
13 Console.ReadKey();
14 }
15 }
16 }
17
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace ConsoleApplication1
6 {
7 class Program
8 {
9 static void Main( string [] args)
10 {
11 // out text to the screen.
12 Console.WriteLine( " hello! " );
13 Console.ReadKey();
14 }
15 }
16 }
17
5、选择Debug|Start菜单项。稍后就会在cmd窗口中显示“hello!”字样的结果。
6、按下任意键,退出应用程序。
现在不仔细研究这个项目使用的代码,而关心如果使用VS启动和运行代码。可以看出,VS做了许多工作,大大简化了编译和执行代码的过程。执行这些简单的步骤还有多种方式。例如在创建一个新项目时也可以按下纯ctrl+shift+n,还可以单击工具栏上相应的图标。