Wen Xin (i)

Source: Internet
Author: User

First, C # basic syntax

1. Annotation characters

    • Single-line Comment: Add "//" in front of the code or text you want to comment
    • Multiline Comment:/* What you want to comment */
    • Document Comment: Press three consecutive "/" on the previous line of the method or class to OK
    • Role: A. Write-off of unused code

B. Explain the code that was written

Key shortcuts used in 2.VS

    • Ctrl+k+d: Quickly align the Code of this page
    • Ctrl+j: Pop Up Smart Tips
    • Ctrl+k+c: Note the selected code
    • Ctrl+k+u: Cancels the comment for the selected code
    • F1: Jump to help document
    • #Region, #EndRegion: Folding redundant code

3. Variables: Used to store data in a computer

    • Requirements for defining variables: A. To determine the stored data type

B. To give the storage space a meaningful name, convenient for us to use later

    • Syntax: A. Variable type variable name; Variable name = value;

B. Variable type variable name = value;

    • Usage rules: Declare first, then assign value, use after
    • Note: The variable for a string can be empty, but the character variable cannot be empty

4. Naming rules

    • Camel case: The first letter of the first word is lowercase, the first letter of each of the remaining words is capitalized; for local variables and method parameters
    • Pascal case: Capitalize the first letter of each word; for type name and member name
    • All caps: Uppercase as the name implies; used for abbreviations

5. Use of the "+" sign

    • String connection (on both sides of the "+" sign if one side is a string type)
    • Numbers are added (when the "+" sign is both numeric types)

6. Use of placeholders: dig holes first, then pits

    • The hole-digging index is starting from 0.
    • Dig n a hole to fill N a pit (more fill, no effect; less fill, throw exception)
    • The order of the outputs is output in the order in which the pits are dug.

* Exception (Exception): In the process of running the program, for some reason the problem, so that the program does not work properly (commonly known as bug)

* error: Refers to a problem with code syntax that causes program compilation to not complete

7. Swap variables

    • Use third-party variables ()
    • Do not use third-party variables (interview written questions, and only apply to numeric types)

8. Type Conversion

    • Explicit conversions (Large range → small range) require write-code conversion

A.convert.toint32 parameters are more, Int.parse can only convert a string of type

B.parse is to convert string into int,char,double .... And so on, that is *. Parse (string) must be a string in parentheses

C.convert can provide multiple types of conversions, that is, convert.* () can be of many types (including string) in parentheses

    • Implicit conversion (small range → wide range) auto-conversion without writing code

[email protected] The role of the symbol

    • Eliminate the escape effect of ' \ ' in a string
    • Output a string in the original format of the edit

10. Common Escape characters

    • \ n : Line Break
    • \ ": Displays double quotation marks in English half-width
    • \t:tab the space of the key
    • \b: Backspace (no effect on both sides of the string)
    • \ \: Displayed as a ' \ '

Wen Xin (i)

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.