C# restart --- language basics 2

1. else and if adopt the principle of nearest matching, else will match with the nearest if

1. If there is only one statement under if, elseif or else, you can write it directly without brackets 

If switch, while, for, etc. in C# are the same as C

2. The case of the switch can only be followed by a certain value

3. And or will stop directly once it is judged to be true or false, and will not continue to judge --- this form is called short-circuit logic

1. When the loop encounters continue, the statement after continue will not be executed again, but directly start a new round of loop

1. The way to generate a random number in C# is as above --- instantiate the object through the class, and then generate a random number through the object call method (given range)

2. The principle of programming: never write the repeated code a second time

3. In C#, the name of the method must be capitalized

4. Once a return is encountered in the method, the method ends directly

5. Be sure to ensure that a method only implements one function! ! , to ensure method reusability and hierarchy

6. The difference between the writeline method and the write method is that the writeline changes the line directly after writing, while the write does not change the line after writing

1. Method overloading can also be called function overloading --- the characteristic of this feature is that when the method names are the same, the computer can distinguish the methods with the same name according to the difference in the parameter list

2. Compared with loops, the performance overhead will increase if recursion is used, because the essence of recursive operations is to open up a stack in memory and perform stack operations continuously. Compared with loops, this is an additional performance overhead point (but recursion has A great advantage is the ability to keep simplifying complex problems)

3. When writing recursion, don't forget the termination condition

Guess you like

Origin blog.csdn.net/qq_51947882/article/details/127561956