c# 中关键字_C#中的“使用”关键字
c# 中關(guān)鍵字
Prerequisite: Namespace in C#
先決條件: C#中的命名空間
If you want to include namespace in a program then we need to use using keyword. For example we use Console class which is defined in System namespace that’s why we need to include System namespace using using keyword.
如果要在程序中包含名稱空間,則需要使用using關(guān)鍵字。 例如,我們使用在System名稱空間中定義的Console類,這就是為什么我們需要使用using關(guān)鍵字包含System名稱空間的原因。
If we want to use Console class without include then we can also access it with the help of . (dot) operator like that:
如果我們想使用不包含include的Console類,那么我們也可以借助來訪問它。 像這樣的(點(diǎn))運(yùn)算符:
System.Console.WriteLine("Hello World");Example:
例:
using System; using System.Collections;using namespace1; using namespace2;namespace namespace1 {class ABC{public void fun(){Console.WriteLine("Inside Namespace1");}} }namespace namespace2 {class XYZ{public void fun(){Console.WriteLine("Inside Namespace2");}} } class Program {static void Main(){ABC OB1 = new ABC();XYZ OB2 = new XYZ();OB1.fun();OB2.fun();} }Output
輸出量
Inside Namespace1Inside Namespace2Read more: Nested Namespace in C#
: C#中的嵌套命名空間
翻譯自: https://www.includehelp.com/dot-net/using-keyword-in-c-sharp.aspx
c# 中關(guān)鍵字
總結(jié)
以上是生活随笔為你收集整理的c# 中关键字_C#中的“使用”关键字的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DNF中组队时物品如何分配?
- 下一篇: c#异常处理_C#中的异常处理