C # basic sorting (1 ),

Source: Internet
Author: User

C # basic sorting (1 ),

1. What is. net?
. Net Has A. net platform and A. Net Framework.
The. net platform contains the. net framework.
The framework provides a stable runtime environment to ensure the normal operation of various applications developed based on the. Net platform.

2. What is C #?
C # is a programming language that can be used to develop applications based on the. net platform.

3. What can. net do?
Desktop Application winform
Internet application asp.net
Mobile development wp8
Unity3d game development or virtual reality

4... net interaction modes
C/S Client/Server mode
B/S Browser/Server mode

5. escape characters
'\' + Special character = character with Special Functions
\ N line feed
\ R \ n windows operating system cannot use \ n, only \ r \ n can be used
\ "Double quotation marks
\ T tab key space
\ B backspace key. It is ineffective to put the string on both sides.
\ Indicates \

6. @ symbol
① Cancel the escape Function of \ In the string, which is expressed as a '\' only '\'
② Output the string in the edited original format

7. type conversion
① Int-> double implicit type conversion (Direct conversion)
② Double-> int explicit type conversion (forced conversion)
Double s = 2.5;
S2 = (int) s;

8. type variables are incompatible
String and int
String and double
You can use the convert conversion factory for conversion.
String str = "123456 ";
Int nums = Convert. ToInt32 (str); // The result is: nums = 123456.

9. Operators and expressions
① Unary operator
Operations completed by only one operand
1) whether it is the prefix ++ or the suffix ++, the final result is to give this variable + 1.
2) In the expression, the first ++ is to add the variable itself to + 1, and then take the value of + 1 into the operation.
The plus ++ takes the original value for calculation. After the calculation is complete, the variable itself is given + 1.
② Binary Operators
+-*/% Operations that require two or more operands
The expression contains both a dollar and a binary element. First, calculate the unary operator.
③ Ternary expression
Syntax: expression 1? Expression 2: expression 3;
Int max = A> B? A: B;
Expression 1 is generally a relational expression.
If the value of A> B is true, the value of A is the value of max.
If the value of A> B is false, the value of B is the value of max.
Note: The type of B must be the same as that of A and be consistent with that of Max.
④ Relational Expression
>,<, ==, >=, <= ,! =
Expressions connected by Relational operators
⑤ Logical expression
&, | ,!
Expressions connected by logical operators
Logical operators are usually placed on both sides of a relational expression or bool type value.
⑥ Compound assignment operator
+ =,-+, * =,/=, % =

10. Structure
Sequence Structure: The program enters from the Main function and runs from top to bottom line without dropping any row.
Branch Structure: if-else
Select structure: if else-if switch-case
Loop Structure: while do-while for foreach

11. try-catch
① Various exceptions often occur in the program. If you don't want the program to crash, try-catch is often used in the Code for exception capture.
② No other code exists between try-catch.
③ If the program in try is not abnormal, the code in catch will not be executed. If an exception occurs in the program in try, even if there are still 100 lines of code after this line of code, the code will be skipped to catch.

12. Scope of Variables
① The scope of the variable is the range in which you can use the variable.
② The scope of a variable generally starts from the braces closest to it and ends with the ending brackets corresponding to the brackets.
③ In this range, we can access and use variables. If the variable is exceeded, it cannot be accessed.

13. switch-case
It is used to process multi-condition value judgment.
Syntax:
Switch (variable or expression value)
{
Case value 1: code to be executed;
Break;
Case value 2: the code to be executed;
Break;
Case value 3: code to be executed;
Break;
..........
Default: the code to be executed;
Break;
}
Execution Process: The program runs at the switch. First, the variable or expression value in the brackets is calculated, and then the value is matched with the value next to each case, once the matching is successful, the code in this case is executed. After the execution is complete, the break is encountered. Jump out of the switch-case structure.

If it does not match the value of each case. Check whether default exists in the switch-case. If default exists, execute the statement in default. If default exists, the switch-case structure will not do anything.

14. for Loop
Forward-order Loop
For + tab
For (int I = 0; I <length; I ++)
Inverted Loop
Forr + tab
For (int I = length-1; I> = 0; I --)

15. parse type conversion
If convert fails to be converted, an exception is thrown. In essence, parse is called.
S = "123 ";
S2 = int. parse (s );
TryParse is a method that converts a string type to an int type and returns true or false.
Int num = 0;
Bool B = int. TryParse ("123abc", out num );
Console. WriteLine (B); // false
Console. WriteLine (num); // nums = 0

16. continue
Continue is generally used in combination with If. When a condition is met, return to the cyclic condition to judge
Difference from break
Continue: You can choose to continue or not execute the loop. execution or not execution depends on whether the loop condition is true or not.
Break: jump out of the loop directly

17. Random Number
Random r = new Random ();
Int number = r. Next (); // a random number ranging from 1 to 10 is assigned to number.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.