每日总结

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 @   哈哈哈老先生  阅读(2)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· 因为Apifox不支持离线,我果断选择了Apipost!
点击右上角即可分享
微信分享提示