My It dream--web the development of the front-end development of software C # basic article (i)

Source: Internet
Author: User
Tags arithmetic operators bitwise operators

C # Programming Fundamentals take you into software developmentfirst, the introduction of development

1.c#=c Sharp

Learn: source code → machine code → computer → console. That is, the source code is translated by the compiler into a machine code that can make the computer read, and output through the console. That is the process of code→compile→run.

2. My first small program (Hello,world)

Step: Create a new text document, rename myfirstprogram.txt→ to find the C # Editor csc.exe file path in My Computer and copy the →windows key +r Open run cmd→ input CD, space, paste path, enter → continue to enter CSC, space,/ Out: (where the program needs to be stored), spaces, the path to the file where the MyFirstProgram.txt is located, and enter.

The code in MyFirstProgram.txt is as follows:

Using System;
public class Program
{
public static void Main ()
{
Console.WriteLine ("Hello,world");
Console.ReadLine ();
}
}

Your first program is finished, run the EXE file, and you will see Hello,world.

2. Development tools

IDE: Integrated development Environment (Integrated development environment)

Common development tools: Java→eclipse,html→webstorm,c#→visuial Studio.

ii. variables and data types

Data types in the 1.c# language

char character type, string string type, int integer type, double decimal type.

2. Variables

Variable declaration: Specifies a piece of memory space for storing data. Syntax: Data type variable name

Variable assignment: Stores the data in the variable's memory space. Syntax: variable name = data

Note: The variable name at the time of assignment must be the same as the variable name at the time of declaration.

The data at the time of assignment must match the data type at the time of the Declaration.

Variables must be declared first and then assigned.

3. Naming of variables

Hard requirements (rules that must be followed): variable names can only consist of numbers, letters, underscores, variable names cannot start with numbers, names cannot be the same as keywords (in VS, blue tag keywords); Variable names must not be the same in the same function (language sensitivity in C #, example a=/a).

Soft requirements (Recommended rules): variable names to be able to look at the text to understand; The first letter of the variable name is lowercase, except for the first word, the other words are capitalized (hump naming).

4. Data operations

5. Input statements

In the console to get user input, the program pauses execution, waits for user input, obtains the user's input, the program continues to execute.

For example, string s=console. Readline ();

return Type: String Type ;

Pauses the program, waits for the user's input, completes the user input and presses the ENTER key, obtains the user input string, saves the string to the variable s.

5. Type conversion

Convert any type of data to string, conversion code: data to be converted. Tostring

Mutual transfer of type int and double type

Value range of the value range of double >int

A numeric type with a small range of values → A numeric type with a large range of values; implicit conversions: No additional code is required and the computer automatically completes the conversion.

Numeric types with large range of values → numeric types with a small range of values; Explicit conversions: Additional code needs to be written, the computer does not automatically convert, and explicit conversions (casts) can cause data loss.

String conversion to numeric type

String→int Int. Parse (string to be converted)

String→double Double. Parse (string to be converted)

6. Escape character

Common escape character: \ "double quotation mark; \ ' single quotation mark; \ n newline character; \ \ \ \ \ \ \ \ Slash \;@ means that there is no escape character in the next string.

7. Number types

8. Errors and debugging in the software

Is the process of discovering errors and solving them.

Errors in the software:

Compilation error: The domain code could not be compiled (vs will error).

Run errors: Error during operation (debug run/non-debug run).

Logic error: The running result does not match the expected.

third, operators and expressions

1. Operators

Operator: Also known as an operator, is a symbol for an operation that acts on one or more operands.

Classification of operators:

By number of operands: unary (mesh) operator, two (mesh) operator, ternary (mesh) operators.

Functions by Operator: arithmetic operators, logical operators, bitwise operators, others.

2. Expressions

3. Operator Precedence

Iv. Process Control

1. Flowchart

Tools for making flowcharts: PPT, Word, Visio, Power Desinger, Diagram Designer, and more.

Functional analysis and code writing separation.

2.if judgment

3.switch selection

4.while Cycle

5.do while loop

Code format:

Do

{

Loop body

}

while (cyclic condition);

The loop body is executed first and then the loop condition is satisfied, if it is satisfied, the loop body is executed, and then the condition is satisfied until the condition is not satisfied before the loop is ended.

6.for Cycle

7.break and Continue

V. Arrays and collections

1. Arrays

Default values for array items

Number type: The default value is 0;

type bool: The default value is false;

Char type: The default value is;

String type: The default value is null.

Reading and modifying array items

READ: variable name [index]

Modify: Variable name [index]= value

Reads the length of an array

The variable name. Length return type: int

2. Collection

3.foreach Cycle

Summary: Learn the above content, you can have a preliminary understanding of C #, programming any heavy and far, after all, the end of paper, the most important or more practice, this is the only way.



  

My It dream--web the development of the front-end development of software C # basic article (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.