每日总结

发布时间 2024-01-09 21:49:09作者: 哈哈哈老先生

C# 基本语法
3.2.1 using关键字
在任何 C# 程序中的第一条语句都是:

using System;
1
一般在程序开头添加 using System;,这时System.String 就可简写为string 。
例如:

// using System;

namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
System.String a = "Hello World!";
System.Console.WriteLine(a);
System.Console.ReadKey();
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

using System;

namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
string a = "Hello World!";
Console.WriteLine(a);
Console.ReadKey();
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
是等价的。
using 关键字用于在程序中包含命名空间。一个程序可以包含多个 using 语句。

3.2.2 class关键字
class关键字用于声明一个类
————————————————
版权声明:本文为CSDN博主「吮指原味张」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/mahoon411/article/details/109442403