Notion original notes
1. Introduction to C#
1.1 C# Definitions
C# inherits the power of C and C++ while removing some of their complexity, making it an efficient and powerful programming language in the C family.
1.2 C# Uses
- Business applications for capturing, analyzing and processing data
- Dynamic web applications accessible from a web browser
- 2D and 3D games
- Financial and scientific applications
- Cloud-based applications
- mobile application
1.3 How C# works
1.3.1 What is a programming language?
Programming languages (such as C#) can be used to write instructions that you want your computer to execute. Each programming language has its own syntax.
The role of a programming language is to allow people to express intent in a human-readable and understandable way.
Instructions written in a programming language are called "source code" or simply "code".
1.3.2 What is compilation?
Special programs called compilers convert source code into other formats (machine code) that can be executed by the **computer's central processing unit (CPU)**.
Why do you need to compile code? Although most programming languages seem difficult to understand at first, they are easier for humans to understand than the preferred language of computers. A CPU understands instructions represented by turning thousands or millions of little switches on or off. A compiler bridges these two worlds by converting human-readable instructions into a computer-understandable instruction set.
2. Environmental configuration
This uses .net8 + vscode
2.1 Download and install VS Code
VS Code official website
2.2 Downloading and installing .Net8
Net official website
Verify that the .Net installation was successful:
typical example
D:\>dotnet --version
8.0.204
2.3 Installing the VS Code C# Extension
2.3.1 Changing the default installation location of VS Code extensions
- First, cut the extensions plugin from the default installation path to the location where you really want it to be stored
commander-in-chief (military)C:\Users\(username)\.vscode\extensions\
Cut to the location where it is stored, here withD:\extensions
e.g.
Be careful not to put it in the same directory as the VS Code installation, as it will be deleted when vscode is updated.
- utilization
mklink
command to create a shortcut using the\D
Parameter Creationsoft link (computing)
Microsoft Windows [version 10.0.19044.1288].
(c) Microsoft Corporation. All rights reserved.
C:\Users\Star Scars Sky>mklink
Creates a symbolic link.
MKLINK [[/D] | [/H] | [/J]] Link Target
/D Creates a symbolic link to a directory. The default is a file
Symbolic links.
/H Creates a hard link instead of a symbolic link.
/J Creates a directory link.
Link Specifies the name of the new symbolic link.
Target Specifies the path (relative or absolute) to which the new link refers.
(relative or absolute).
C:\Users\Star Scars Sky>.
importationmklink /D "<original path>" "<path where it's really stored>"
The example here is:mklink /D “C:\Users\star scarSky\.vscode\extensions” “D:\extensions”
Just see the output of a successful creation
2.3.2 Installing C# Extensions
The extensions to be installed are as follows
- IntelliCode for C# Dev Kit
(After installing this, the following will also be installed automatically)
- C#
- C# Dev Kit
- .Net Install Tool
3. First line of code: Hello World
3.1 Hello World!
("Hello World!");
exports
Hello World!
Note: C# is case-sensitive, for example, do not Console wrongly entered into the console, single and double quotes can not be mixed
incorrecttypical example
('Hello World!');
exports
(1,19): error CS1012: Too many characters in character literal
The 19th character on line 1 identifies the problem, followed by the error message
3.2 and
Distinction:Added at the end
\n
line breakhave not