Guide to the Language


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

CHAPTER 1
Hello World
 Choosing an IDE
To begin coding in C#, you need an Integrated Development Environment 
(IDE) that supports the Microsoft .NET Framework. The most popular 
choice is Microsoft’s own Visual Studio.
1
This IDE is available for free as a 
light version called Visual Studio Community, which can be downloaded 
from the Visual Studio web site.
2
The C# language has undergone a number of updates since the initial 
release of C# 1.0 in 2002. At the time of writing, C# 8.0 is the current version 
and was released in 2019. Each version of the language corresponds to a 
version of Visual Studio, so in order to use the features of C# 8.0, you need 
Visual Studio 2019 (version 16.3 or higher).
Note When installing Visual Studio, be sure to select the “.NET 
desktop development” and “.NET Core cross-platform development” 
workloads in order to be able to use C# 8.0.
1
 www.visualstudio.com
2
 www.visualstudio.com/vs/community/


2
 Creating a Project
After installing the IDE, go ahead and launch it. You then need to create 
a new project, which will manage the C# source files and other resources. 
To display the New Project window, go to File ➤ New ➤ Project in Visual 
Studio. From there, select the “Console App (.NET Core)” template and 
click the Next button. Configure the name and location of the project
if you want to and then click Create to allow the project wizard to create 
your project.
You have now created a C# project. In the Solution Explorer pane 
(View ➤ Solution Explorer), you can see that the project consists of a single 
C# source file (.cs) that should already be opened. If not, you can double- 
click the file in the Solution Explorer in order to open it. In the source file, 
there is some basic code to help you get started. However, to keep things 
simple at this stage, go ahead and simplify the code into this.
class MyApp
{
static void Main()
{
}
}
The application now consists of a class called MyApp containing an 
empty Main method, both delimited by curly brackets. The Main method 
is the entry point of the program and must have this format. The casing 
is also important since C# is case-sensitive. The curly brackets delimit 
what belongs to a code entity, such as a class or method, and they must be 
included. The brackets, along with their content, are referred to as code 
blocks, or just blocks.
ChapTEr 1 hEllo World


3

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