C#基础-1


c#基础入门其一:

c# 既 c sharp

依附于.NET平台

c/c++ 编译器 机器指令

C# 编译器 IL中间语言 .NET CLR 机器指令

创建Csharp代码后,因为部分教程用的.NET平台版本为.net6以下,因此会生成以下模版:

using System;

namespace xxx
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

其中 namespace 中为命名控件
internal class 中为类型, class 为关键字,编译器看到关键字后会进行相应编译。
static也为关键字,从main函数开始运行,一个类型套一个函数。

而Net6以上则会隐藏该格式
直接显示

// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

该代码为输出Hello, World!,感觉类似于c++中的printf语句233。


文章作者: waterfish
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 waterfish !
评论
  目录