官术网_书友最值得收藏!

  • Learn C# in 7 days
  • Gaurav Aroraa
  • 330字
  • 2021-07-08 09:51:21

Understanding a typical C# program

Before we start writing a program in C#, let's first go back to day one, where we discussed the various IDEs and editors that are helpful in writing programs/applications using the C# language. Revisit day one and understand various editors and IDEs and check why we should go with one of our choice. We will be using Visual Studio 2017 update 3 for all our examples in this book.

To know the steps to install Visual Studio 2017, refer to https://docs.microsoft.com/en-us/visualstudio/install/install-visual-studio.

To get start with a simple C# program (we will create a console application), follow these steps:

  1. Initiate your Visual Studio.
  2. Go to File | New | Project (or ctrl +Shift + N).
  3. Under Visual C# node, select .NET Core and then select Console App.
  4. Name your program, say, Day02, and click on OK (see highlighted text in the following figure):

You will get the following code in class Program.cs – this is the default code provided by Visual Studio; you can amend it as per your need:

using System; 
 
namespace Day02 
{ 
class Program 
    { 
     static void Main(string[] args) 
        { 
         Console.WriteLine("Hello World!"); 
        } 
    } 
} 

By hitting the F5 key on your keyboard, you will run the program in Debug mode.

Typically, every program has two different configurations or modes, that is, Debug and Release. In Debug mode, all compiled files and symbols that are helpful to drill down any issue encountered during the execution of application will be loaded. On the other hand, Release is kind of a clean run, where only binaries without Debug symbols load and perform the action. For more information, refer to https://stackoverflow.com/questions/933739/what-is-the-difference-between-release-and-debug-modes-in-visual-studio.

You can see the following output when the program runs:

Before moving further, let's analyze the following figure of our console application on Visual Studio:

The preceding figure depicts a typical C# program; we are using Visual Studio, but the console program remains unchanged across different IDEs or editors. Let's discuss this in more detail.

主站蜘蛛池模板: 射洪县| 莒南县| 乐业县| 巴马| 读书| 麟游县| 化州市| 文昌市| 依安县| 阿鲁科尔沁旗| 新乡县| 兴城市| 双柏县| 北碚区| 根河市| 平顶山市| 沈阳市| 库伦旗| 滨州市| 平谷区| 靖安县| 利川市| 武邑县| 乌审旗| 同心县| 仪征市| 武邑县| 保亭| 千阳县| 江西省| 镇原县| 临海市| 古丈县| 金山区| 田东县| 石渠县| 鲁山县| 巴彦淖尔市| 朝阳区| 呼和浩特市| 荔波县|