Let's get to know the sample code we used in previous examples.
Which was(C-1-1):
- This line of code tells the computer to use some tools that will help write the program. which contains a variety of useful classes and methods for working with the .NET framework.
2nd Line: Blank Line
- C# will ignore blank spaces. However, blank lines make the code more readable and clean.
3rd Line: namespace MyFirstProgram{}
- This line of code gives a name to the collection of tools called MyFirstProgram which we will be using in the program. A namespace is used to organize code and prevent naming conflicts.
5th Line: class program{}
- This line of code says that we are going to create a new thing (called a "class") and that we will call it a "program". A class is a blueprint for creating objects that can contain data and methods.
7th Line: static void Main (string[] args){}
- This line of code says that we are creating a special part of the "Program" thing called "Main" that the computer will use to start the program. It also says that this part of the program can take some information when it starts which we call "arguments".
9th Line: Console.WriteLine("Hello world!");
- This line of code says that the program should print the message "Hello world!" to the screen when it starts. This WriteLine method of the Console class adds a newline character at the end of the string, so each call to WriteLine outputs the string on a new line.
إرسال تعليق