<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # C# Hello World - 您的第一個 C# 程序 > 原文: [https://www.programiz.com/csharp-programming/hello-world](https://www.programiz.com/csharp-programming/hello-world) #### 在本教程中,我們將學習如何編寫一個簡單的 HelloWorld C# 中的程序。 這將使您熟悉 C# 程序的基本語法和要求。 HelloWorld 程序通常是我們使用一種新語言時看到的第一個程序。 它僅在輸出畫面上打印 **HelloWorld**。 該程序的目的是使我們熟悉編程語言的基本語法和要求。 * * * ## C# 中的 HelloWorld ```cs // Hello World! program namespace HelloWorld { class Hello { static void Main(string[] args) { System.Console.WriteLine("Hello World!"); } } } ``` 運行該程序時,輸出為: ```cs Hello World! ``` * * * ## 怎么樣? C# 中的程序有效嗎? 讓我們逐行分解程序。 1. `// Hello World! Program` `//`表示 C# 中注釋的開始。 注釋不是由 C# 編譯器執行的。 它們旨在使開發人員更好地理解一段代碼。 要了解有關 C# 中注釋的更多信息,請訪問 *C# 注釋*。 2. `namespace HelloWorld{...}` `namespace`關鍵字用于定義我們自己的命名空間。 在這里,我們創建一個名為`HelloWorld`的命名空間。 只是將命名空間視為由類,方法和其他命名空間組成的容器。 要獲得命名空間的詳細概述,*請訪問* [C# 命名空間](/csharp-programming/namespaces "C# namespaces")。 3. `class Hello{...}` 上面的語句在 C# 中創建一個名為-`Hello`的類。 由于 C# 是一種面向對象的編程語言,因此創建類對于執行該程序是必不可少的。 4. `static void Main(string[] args){...}` `Main()`是 Hello 類的方法。 每個 C# 程序的執行都從`Main()`方法開始。 因此,C# 程序必須具有`Main()`方法。 `Main()`方法的簽名/語法為: ```cs static void Main(string[] args) { ... } ``` 我們將在后面的章節中詳細了解這些方法。 5. `System.Console.WriteLine("Hello World!");` 現在,請記住,這是打印 **HelloWorld** 的代碼。 轉到輸出屏幕。您將在后面的章節中詳細了解其工作原理。 * * * ## 備選 HelloWorld 程序 這是寫 HelloWorld 的另一種程序。 ```cs // Hello World! program using System; namespace HelloWorld { class Hello { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } } ``` 請注意,在這種情況下,我們在程序開始時編寫了`using System;`。 通過使用這個,我們現在可以替換 ```cs System.Console.WriteLine("Hello World!"); ``` 與 ```cs Console.WriteLine("Hello World!"); ``` 這也是我們在以后的章節中將要使用的一種便利。 * * * ## 本文中要記住的事情 * 每個 C# 程序都必須具有一個類定義。 * 程序的執行從`Main()`方法開始。 * `Main()`方法必須在類定義內。 這只是一個將 C# 引入新手的簡單程序。 如果您不了解本文中的某些內容,那也可以(即使我剛開始時也沒有理解)。 隨著本教程系列的進行,一切都會變得有意義。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看