每日总结

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 语句。



posted @ 2024-01-09 21:46  哈哈哈老先生  阅读(1)  评论(0编辑  收藏  举报