Beginner C # Experience

Source: Internet
Author: User
Tags arithmetic operators bitwise operators logical operators variable scope

C # is an object-oriented, high-level programming language running on the. NET framework that Microsoft publishes. And is scheduled to debut on the Microsoft Career Developer Forum (PDC). C # is the latest achievement of Microsoft researcher Anders Hejlsberg. C # looks surprisingly similar to Java, and it includes processes such as single inheritance, interfaces, almost the same syntax as Java, and the process of compiling into intermediate code. But C # differs significantly from Java in that it draws on a feature of Delphi, which is directly integrated with the COM (Component Object model), and is the protagonist of Microsoft's. NET Windows network Framework.

In the process of learning, the first need to master the basic statement. For example: Enter the statement console.write ("xxx"), and when the program runs to this phrase, output double quotes in the console. Input statement: Console.ReadLine (); Input statement, the program runs to this sentence, pause waiting for the user's input.

The computer can only recognize the high and low levels of the state, it can only use two digits (0-1) to represent, therefore, when the arrival of two, the number is not enough, you have to enter one, which is called every two in one. The concept of a binary command program that can be understood and executed by the CPU is actually very simple, and a single instruction can do one thing, and multiple instructions can do more things. It is a program to string up and line up a number of instructions in a certain sequence.

Popular point is the source code, we can usually create a new TXT text format file, and then start coding. But the text computers that we encode directly do not recognize them. After we have finished coding, we need to convert the source code into a binary code that the computer can recognize, i.e. compile. Generates an executable EXE file. Run the executable file with an EXE suffix after the compilation is complete.

An int that represents an integer type, directly representing no formatting, such as 1, 2, 3, 4. A double represents a real type, directly representing no formatting. such as 0.0, 1.2.-1.5. String, which is the type of strings, in double quotation marks, the contents of which can be blank, such as "," 1 "," word ". Char represents a single character.

The meaning of a variable: used to save a number, he is a pronoun, refers to the number of his saved. , single quotes indicate that there must be content in single quotes, such as ' 1 ', ' word '. The essence is shaping. Declaration of a variable: General data type + variable name. such as int A; double A; variable name: Only one number, letter, underscore, cannot start with a number. The name of the variable must not be the same as the keyword. If the variable name is a combined word, then the first letter is lowercase and the first letter of each word is capitalized, called the Hump naming method. Variable assignment: The basic form is the data type + space + variable name, for example: int number, and then number=5, "=" At this time is an assignment symbol, indicating that the value of "5" is assigned to the variable of number to store.

Type conversion: String to double: double A = double.parse ("amount to change"); string to int: with int a = Int.parse ("amount to be converted"); int to string: string a = amount to be converted. ToString ();d ouble to string: string a = amount to be converted. ToString ();d ouble to int:int a = (int) to be transformed; int to double: No additional code required, direct conversion. Display conversion: The large range of values is converted to a small range of values. Implicit conversions: The conversion of a small range of values into a large range of values. The basic concept of escape characters: When we enter the program, we encounter a lot of symbols overlap with the symbols in our program, causing us to recognize the computer incorrectly when we use it. So you need the escape character to redefine the program text. Escape character classification: The basic form is a \, double-quote escape character: \ "content \", single quote: \ ' content \ ', line break: \ n, slash: \ \ contents \, tab: \ t.

The basic concept of an operator is an operator, which is a symbol for operations. It acts on one or more operands. Operator classification: one-mesh operator, two-mesh operator, and trinocular operator. Categorized by Function: arithmetic operators, logical operators, bitwise operators, others.

bool Operation rule: && Two Boolean types in this state are calculated, except that all true results are true, and all others are false. | |, the two boolean types in this state are calculated, except that all false results are false, and all others are true. , in this state, only suitable for a single Boolean type, the true result is false, the false result is true.

The concept and significance of flowchart: Using standardized graphic scheme to analyze the implementation steps of a function. Flowchart procedure: function → flowchart → implementation code. Flowchart the meaning of each pattern: ellipse: Start or end. Square: Step. Parallelogram: Represents the input output. Diamond: to indicate judgment. Arrows: Indicates program flow. Process Control statement: if judgment

The basic structure is as follows:
if (condition 1) {Code 1}
else if (condition 2) {Code 2}
else if (condition 3) {Code 3}
else{Code N}
First, the program runs to this place, after the condition 1 judgment, if the program satisfies the condition 1, executes the code 1. If the condition is not satisfied, skip condition 1 and run the second sentence program. The same is the first judgment after execution. Note: In an If program, there can be no else if and else, but must have if, and else if can have an unlimited number, else can be 1 or 0.

Swith selection:

Swith (variable expression)
{Case value 1;
Code 1
Break
Case value 2;
Code 2
Break
Default
Code n
Break
} represents the selected statement, when the result of the variable expression is the same as the code value 1 and the value 2 below, the program executes the code corresponding to the value. Pay attention to break.

Loops: While

while (loop condition) \ \ The loop condition in this must be a bool
{Execute code}
When the previous program executes to this step, the first will pass the loop condition judgment, if the judgment result is true, then executes the code, then returns the result to the previous step to continue to judge, if the result is true, continues executes, continues to return, has been circulating. Until the loop condition is judged to be false, end the loop.

Do While

The basic form of the Do and loop is as follows:
do{Execution Program

while (loop condition)
Unlike the while loop, when we execute this program, the do is executed first, while the while is executed from the program input, and our do is executed before the execution of the program begins to enter the loop condition.

For

The basic form of a For loop:
int A;
for (a=5; cyclic condition; a++)
This means that in the case of satisfying the cyclic condition, a is used as the initial value and the a++ is self-increment. (Of course a--can also). The data loop.

foreach, used for iterating over arrays or collections.

Variable scope: You can simply understand that a variable is in the curly brace where it was defined, that the variable is valid in curly braces, and that the variable is not valid outside the curly braces.

Beginner C # Experience

Related Article

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.