You are currently viewing this course as Guest.
Program Structure in C#
To implement a programming language, the "Hello, World" program is traditionally used. It's here in C #:
static void Main ()
- The program "Hello, World" begins with a command that references the namespace of the framework.
- A hierarchical means of organizing C # programmes and libraries is supported by namespaces.
- The Hello class declared by the "Hello, World" programme has a single member, the method called Main.
- With the static modifier, the main method is declared. A static method called Main, by convention, serves as the entry point of a C # programme.
- The performance of the programme is provided by the WriteLine method of the Console class in the System namespace.
- The standard class libraries support this class, which by default are referenced automatically by the compiler.
Let us look at the different components of the given programme-
- To use the framework namespace in the application, the first line of the programme that uses Framework;-will use the keyword. Generally, a programme uses statements in many forms.
- The next line has the declaration of the namespace. A namespace is a class set. The namespace of HelloWorldApplication includes the HelloWorld class.
- The next line has a class statement, and the HelloWorld class includes the descriptions of data and methods that your software uses. Generally, groups include several techniques.
- The first line of the software that uses the framework would use the keyword in order to use the framework namespace in the document. Generally, in certain forms, a programme uses statements.
- The next line has the declaration of the namespace. A namespace is a fixed class. HelloWorldApplication's namespace contains the HelloWorld class.
- There is a class declaration in the next paragraph, and the HelloWorld class contains the data definitions and methods that are used by your applications.
The following points should be noted −
- C # will be case sensitive.
- All sentences and phrases must conclude with a semicolon (;).
- The execution of the programme begins with the primary process.
- The programme file name could be different from the class name, unlike Java.
Program Compilation and Execution
If you are using Visual Studio. Net to compile and run C # programmes, take the steps below −
- Launch Visual Studio.
- Please select File-> New-> Project from the menu bar.
- From the models, choose Visual C #, and then choose Windows.
- Select Program for Console.
- Specify a project name and press the OK button.
- This develops a new Solution Explorer project.
- In the Code Editor, write code.
- To execute the project, click the Run button or press the F5 key. A Command Prompt window that includes the Hello World line appears.