C#第一章

来源:互联网 发布:linux ping 测试 带宽 编辑:程序博客网 时间:2024/05/24 08:33

小试visual studio,感觉debug比code blocks好用,F9直接设置断点,F5运行程序/从断点继续

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Hello_world.cpp{    class Program    {        static void Main(string[] args)        {            Console.WriteLine("Hello World!");            Console.ReadKey();        }    }}

小程序,和java类似,就是从System.Println 变成了 Console.WriteLine

Console.WriteLine(): an object “Console” has a method WriteLine()”. Output text to stdout



///注释可将注释内容放到IntelliSense中



Namespaces(命名空间)
Console:Only a type among tremendous (极好的,巨大的)types in.NET FCL(Framework (框架)ClassLibrary).
Namespace:solutionfor the unique Nameof class in C#.
维基百科上的一个小例子
设Bill是X公司的员工,工号为123,而John是Y公司的员工,工号也是123。由于两人在不同的公司工作,可以使用相同的工号来标识而不会造成混乱,这里每个公司就表示一个独立的命名空间。如果两人在同一家公司工作,其工号就不能相同了,否则在支付工资时便会发生混乱。
目的是为了:
这一特点是使用命名空间的主要理由。在大型的计算机程序文档中,往往会出现数百或数千个标识符。通过将逻辑上相关的标识符组织成相应的命名空间,可使整个系统更加模块化











0 0