Preface
Choose "C # Getting Started Classic Fifth Edition" As a self-study book, to record the learning process notes and experience.
C # Simple Introduction
1. C # is a block-structured language
2. C # distinguishes between uppercase and lowercase
C # variables
C # variable definition is similar
I. Types and definitions of variables
Shaping and scope definition
Floating-point and range definitions
float and double to ±m? 2 e The form of storing floating-point numbers
Decimal to ±m? ten e The form of storing floating-point numbers
Character type and range definition
Character face
Note: strings are reference types, and other types are value types. Variables must be initialized before they are used.
Escape character
1. All escape sequences contain a backslash symbol. followed by a combination of characters.
2. If you assign an initial value to a string. The string itself has a double-argument, so you need to use the sequence \ "to convert the double-argument.
Like what:
"my \"String\" is ";
3. Use the "Unicode" escape sequence to specify Unicode characters that contain the standard \ characters followed by a U and a 4-bit hexadecimal value. Example: \ ' is equivalent to \u0027
Verbatim specifying a string (@)
That is, all characters between the two double-quotes are contained in a string (including line breaks, spaces, and so on), containing the end of the line character and the characters that need to be escaped (except for the escape of the double-argument character).
1. In a verbatim-specified string, you cannot use a double-argument escape, and you need to express the double-argument in the following way, for example:
@"my ""String"" is ";
2. In the verbatim specified string. Can have a line break operation
@"my String is";
Second, the definition of variable name rules
1. There are two naming conventions in the. NETFramework namespace, called Pascalcase and CamelCase, which are applied to multiple word names, and each word in the specified name is lowercase unless the first letter is capitalized.
2. In Camelcass, another rule. That is, the first word starts with a lowercase letter.
3.Microsoft recommendation: For simple variables. Use the CamelCase rule. For advanced naming use Pascalcase (according to conventions, namespaces are usually named Pascalcase)
An expression
Operators fall into three categories: unary operators. Handle one operand, binary operator, handle two operands, three operators, handle three operands
Mathematical operators
1.bool variables are not available for mathematical operators. If the char variable is added, a number is given (its type is int), because the char variable actually stores the number.
2. The two-dollar operator + can be used for processing string-type variables, resulting in a connection value of two strings. However, other mathematical operators cannot be used to process strings.
Increment and decrement
operator before the operand, the operand is affected by the operator before any other calculation is performed, and the operator is placed after the operand, and the operand is affected by the operator after the completion of the evaluation of the expression.
Assignment operators
The + = operator can also be used for strings, as with the + operator
Precedence of Operators
< C # Getting Started classic > Learning Note 1 The first knowledge of C #