Guide to the Language


Download 2 Mb.
Pdf ko'rish
bet6/78
Sana30.04.2023
Hajmi2 Mb.
#1414515
TuriGuide
1   2   3   4   5   6   7   8   9   ...   78
Bog'liq
C sharp

 Hello World
As is common when learning a new programming language, the first 
program to write is one that displays a “Hello World” text string. This is 
accomplished by adding the following line of code between the curly 
brackets of the Main method.
System.Console.WriteLine("Hello World");
This line of code uses the WriteLine method, which accepts a single 
string parameter delimited by double quotes. The method is located inside 
the Console class, which belongs to the System namespace. Note that 
the dot operator (.) is used to access members of both namespaces and 
classes. The statement must end with a semicolon, as must all statements 
in C#. Your code should now look like this.
class MyApp
{
static void Main()
{
System.Console.WriteLine("Hello World");
}
}
The WriteLine method adds a line break at the end of the printed string. 
To display a string without a line break, you use the Write method instead.
 IntelliSense
When writing code in Visual Studio, a window called IntelliSense will pop 
up wherever there are multiple predetermined alternatives from which 
to choose. This window is very useful and can be brought up manually by 
pressing Ctrl+Space. It gives you quick access to any code entities you are 
able to use within your program, including the classes and methods of 
the .NET Framework along with their descriptions. This is a very powerful 
feature that you should learn to use.
ChapTEr 1 hEllo World


5
© Mikael Olsson 2020 
M. Olsson, C# 8 Quick Syntax Reference
https://doi.org/10.1007/978-1-4842-5577-3_2
CHAPTER 2
Compile and Run
 Visual Studio Compilation
With the Hello World program completed, the next step is to compile and 
run it. To do so, open the Debug menu and select Start Without Debugging, 
or simply press Ctrl+F5. Visual Studio will then compile and run the 
application, which displays the string in a console window.

Download 2 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   ...   78




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling