下载安装 Microsoft Visual C# 2010 Express
下载地址:http://msdn.microsoft.com/downloads
实例说明:
/*
Example1_1.cs
该程序显示:Hello World !
以及当前的日期,时间
*/
class Example1_1
{
static void Main(string[] args)
{
//display "Hello World!!" on the screen
System.Console.WriteLine("Hello World!!");
//display the current date and time
System.Console.WriteLine("The current date and time is "+ System.DateTime.Now);
}
}
以上称为源文件(source file)
Method (函数): self-contained unit of code that carry out a specific task, and they typically consist of one or more program line.
以上Main为一个函数。
Fields: named storage areas where you can store values.
Static 关键字,使得Main函数属于该类(Class),如果没有关键字,则要首先创建该类的一个对象,然后Call main函数(first create an object of the class and then call the method)。
void 关键字, 只是main函数不返回任何值。
System.Console.WriteLine 将当前行终止符写入标准输出流。
(学习资源:http://msdn.microsoft.com/zh-cn/library/system.console.writeline.aspx)
Microsoft Visual C# 2010 Express
File->New Project->Console Application->命名:MyConsoleApplication1.Program
(快捷键 Ctrl+Shift+N)
在原码上添加修改:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/*
Example1_1.cs
该程序显示:Hello World !
以及当前的日期,时间
*/
namespace MyConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//display "Hello World!!" on the screen
System.Console.WriteLine("Hello World!!");
//display the current date and time
System.Console.WriteLine("The current date and time is "+ System.DateTime.Now);
}
}
}
纠错:Debug->Build Solution
(快捷键 Ctrl+Shift+B)
运行:Debug->Start Debugging
( 快捷键 Ctrl+F5)
运行结果:
下载地址:http://msdn.microsoft.com/downloads
实例说明:
/*
Example1_1.cs
该程序显示:Hello World !
以及当前的日期,时间
*/
class Example1_1
{
static void Main(string[] args)
{
//display "Hello World!!" on the screen
System.Console.WriteLine("Hello World!!");
//display the current date and time
System.Console.WriteLine("The current date and time is "+ System.DateTime.Now);
}
}
以上称为源文件(source file)
Method (函数): self-contained unit of code that carry out a specific task, and they typically consist of one or more program line.
以上Main为一个函数。
Fields: named storage areas where you can store values.
Static 关键字,使得Main函数属于该类(Class),如果没有关键字,则要首先创建该类的一个对象,然后Call main函数(first create an object of the class and then call the method)。
void 关键字, 只是main函数不返回任何值。
System.Console.WriteLine 将当前行终止符写入标准输出流。
(学习资源:http://msdn.microsoft.com/zh-cn/library/system.console.writeline.aspx)
Microsoft Visual C# 2010 Express
File->New Project->Console Application->命名:MyConsoleApplication1.Program
(快捷键 Ctrl+Shift+N)
在原码上添加修改:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/*
Example1_1.cs
该程序显示:Hello World !
以及当前的日期,时间
*/
namespace MyConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//display "Hello World!!" on the screen
System.Console.WriteLine("Hello World!!");
//display the current date and time
System.Console.WriteLine("The current date and time is "+ System.DateTime.Now);
}
}
}
纠错:Debug->Build Solution
(快捷键 Ctrl+Shift+B)
运行:Debug->Start Debugging
( 快捷键 Ctrl+F5)
运行结果:
![](https://img-my.csdn.net/uploads/201212/11/1355239858_4298.png)