C#學習之“HelloWorld”

來源:互聯網
上載者:User

標籤:

首先,先簡要區別一下C#的開發工具Visual Studio 2013.net Framework 以及 C# 的關係

        .net Framework 是運行環境,用.Net開發出來的東西都要依賴這個運行環境才能運行!而C#是依賴於.Net 平台的進階程式設計語言,Visual Studio 2013

    一個提供IDE(Integrating Development Environment 整合式開發環境)用來開發C# 應用程式的工具。  

      Visual Studio 2013 是IDE(整合式開發環境),它包括了編譯器,協助工具輔助(如Visual Studio 中的屬性視窗之類),以及.Net FrameWork(其中包含

    類、庫、公用語言運行庫)

      這三者感覺像是分別對應著EclipseJDKjava

然後,便是HelloWorld的源碼:

 

    

    namespace HelloWorld
    {

      //Declares a single type: class Program
      class Program
      {

        //Special method(function):Main()

        //CLR(公用語言運行庫) will call the Main()

        static void Main(string[] args)
        {

          //Namespace:solution for the unique Name of class in C#,like System

          //我們也可以在代碼開始寫 "using System;"。

          System.Console.WriteLine("Hello World!");
        }
      }
    }

然後,是對程式的改進

    改變控制台字型顏色:“Console.ForegroundColor = ConsoleColor.Blue;”;

    改變控制台字型背景(個人感覺極醜):“Console.BackgroundColor = ConsoleColor.Yellow;”;

    附一張:

    

    

最後,記錄程式過程中遇到的問題:

    在按了F5之後程式閃退的問題:可以在最後寫一行Console.ReadLine();

                   也可以用Ctrl + F5

                   也可以在程式中設定斷點

    F5啟動調試。就是先產生解決方案再執行的。

    Ctrl + F5開始執行(不調試):直接執行,只得到最終結果。(最後好像預設有一個中斷)

    這兩種方法的區別是,前者需要載入偵錯符號,允許在運行過程中中斷,並逐步執行,還可以對某些變數進行監控,甚至改變其代碼並重新計算;後者僅僅編譯並運行

    ,無法對程式進行調試,僅適合在需要查看運行效果時使用。

 

C#學習之“HelloWorld”

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.