C# 初学笔记_1

下载安装 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)
运行结果:
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值