This is the second day of my participation in the August More text Challenge. For details, see: August More Text Challenge

One, C# program structure

The key organizational concepts in C# are programs, namespaces, types, members, and assemblies

C# program structure features:

  1. C# programs are hierarchically organized by namespaces.
  2. Each namespace can contain several types, the most important of which are classes;
  3. C# classes can contain zero or more data members and zero or more function members. Methods are the most common type of function member we write;
  4. Each function member of a C# class consists of several statements.

1.1 class structure

The general form of a C# program class is:

classClass name {member definition// Such as fields, methods, etc
}
Copy the code

1.2 Method Structure

The general form of the method is as follows:

[staticAccess modifier method return value type Method name (parameter list) {declare part execute statement}Copy the code

Two, example explanation

C# Hello World instance

using System;

namespace VSProject
{
   class Program / / the name of the class
   {
      // The Main method, the program entry
      static void Main(string[] args) 
      {
         // Output statements
         Console.WriteLine("Hello World");
         // The program waits for the action of a key to prevent the operation from flashing by without seeing the effectConsole.ReadKey(); }}}Copy the code

A C# program consists of the following parts:

  • Namespace declaration
  • A class
  • A Class method
  • The Class attribute
  • A Main method
  • Statements & Expressions

Third, development tools

Download and install the development tool Visual Studio, a good tool can be very good to help us improve learning and development efficiency.

  • Code highlighting (customizable), auto-completion, and formatting are very developer friendly.

VS looks something like this when opened

Execute C# program flow using VS compilation:

  1. Start Visual Studio.
  2. On the menu bar, choose File -> New -> Project.
  3. Select Visual C# from the template, then select Windows.
  4. Select Console Application.
  5. Give your project a name and click the OK button.
  6. The new project appears in Solution Explorer.
  7. Write the Code in the Code Editor.
  8. Click the Run button or press the F5 key to Run the program. A Command Prompt window displays Hello World.