C ා learning 3


11   Two ways to run code pressF5Or click Run (right arrow)

12   In the process of programming, pay attention to write notes and appropriate names (notesEasy to find the wrong nameEasy to find)

13   //”Represents a comment symbol

14   The annotator plays two roles: cancellation and interpretation. First, the line of code will not be executed; second, the content after the double slash serves as an explanation for the code below or above.

15   C#Three kinds of annotators for1 Single-Line Comments //    2 multiline comment /*What to comment on*/  3Document annotations are often used to annotate classes or methods

16  When the program has a programming error (no semicolon at the end of the line), it cannot passctrl+k+dTo automatically align the programming lines

17  When pressedHomeKey, the input vertical bar will move to the head of the line; use theshift+homePartial codes from the original location to the line header can be selected;

When pressedEndKey, the input vertical bar will move to the end of the lineshift+endSelect the code from the original position to the end of the line;

18  #regionand#endregionIt appears in the first line and last line of a paragraph. Its function is to fold the code and play a succinct role. It is more convenient to compile subsequent code (the folded code can still run during the running process). It can also be folded up one part by one in the programming of multiple parts, and the code can be folded up in the program of multiple parts#region (blank) mark the whole function of this code with Chinese characters or English, which is convenient for self checking and error checking, and also convenient for other people to work with their own code.

19 If you want to know something you don’t know (e.gint console ), enterC#Document viewhttps://docs.microsoft.com/zh-cn/dotnet/csharp/

Next part

1Variables are used to store data in a computer.

In computer operation, in addition to the memory currently used in computer operation, there are still some parts that are not in use. What we are doing is to open up a piece of memory in the current available memory to use. For different data types [integer, floating-point number (the number contains a few digits after the decimal point, can be an integer or a decimal), string] should be used differently Data type space (such asint ,double,stringEtc.). When we store data, we should first determine the type of data to be stored, and give this part of memory a name to facilitate the use of these data in the following code.

2 Syntax for storing variables

Variable type  Variable name;

Variable name=Data;

For example, storage100

// Declare or define aintVariable of type;

int  number//In the memory opened up a block can store integer space

//Assign a value to this variable

number=100/*take100It’s stored in this space(At this point“=”The value on the right is assigned to the variable on the left)*/


Short form for declaring and assigning values to variables: Variable type Variable name=Value;


doubleIt can be applied to floating-point numbers or integers


stringIt is applied to strings, such as “Zhang San Jia Carlos files and files”,string n=Heaven and earth create the world together with youlove12521”(Half angle of quotation marks)


charApply to characters such aschar n=’Na ‘

Relationship between string and character: string can be empty string, character cannot be empty character, string is composed of characters, it can be understood that book is composed of pages.


decimalThe type of money used to store money is as follows:decimal money=5000m(backmThe role of is to reduce the carry error, increase the number of decimal points, increase the accuracy, effective playdecimalAdvantages of high effective numbers)

3data type

(1)Integer type:int  It can only store integers, not decimals;

(2)Floating point type:doublefloatdecimal Stores floating-point numbers (integers and decimals), wheredecimalBecause of its higher precision and smaller range, it is suitable for financial and financial calculation;

(3)String type:string It is used to store multiple texts or empty texts. String type values need to be enclosed by double quotation marks (half English);

(4)Character type:char It can only be used to store one character, at most one character, at least one character, and cannot be empty. The value of character type needs to be enclosed in single quotation marks (half English);

Recommended Today

Blog based on beego, go blog

Go Blog A beego based development, can quickly create personal blog, CMS system Include functions see Official website of go bloggo-blog.cn Demo siteleechan.online Update log time function January 23, 2020 New top post function February 2, 2020 New custom navigation function February 4, 2020 New site announcement function February 6, 2020 New link module February […]