Follow the video to learn C # ASP. NET the next day

Source: Internet
Author: User

Course Highlights:

Think of variables as containers that hold data
to define variables: type variable names; int i3; variables are only containers and must be placed in values to make sense, otherwise there is no meaning.
int i2=5;
Types of variables: different types of containers put different things. You cannot place a string in a variable of type int. The
variable cannot be placed on data that is incompatible with the variable type.
String, int, char, bool long, and so on. The value of bool: true, False. Represents the range of int. Long has a long
Why does the output "want to use escape character" \ ", because the compiler defaults to encountering" start string, and then "is the end string, but if you encounter the previous \" Do not treat it as a string starting meaning. " \ means do not take the "after" as the beginning or end of the string
Why should have an escape character, that is, in the program to output the special characters such as carriage return, can not be directly in the string to enter, so must be transferred. "\ n" carriage return. String: "\" Ab\ "", "Ab\nb", "C:\\a.txt", @ "C:\a.txt" (recommended). @ means \ is not treated as an escape character in a string. @ You can also define multiple lines of text. "\\\\" gets two \
"\" in the \ is to tell the compiler not to take this "as the end of the string." The
@ is not treated as an escape character. @ is not omnipotent, does not solve the problem of double quotes in the string, if there is a double quotation mark or escape character
Simple type conversion: convert.tostring (), ToString (), Convert.ToInt32 (). You can use the middle variable or not. int i = Convert.ToInt32 (Console.ReadLine ());
naming rules for variables:
The first character must be a letter or an underscore (_), and the following character can be any number, letter, or underscore. You cannot use all C # keywords, such as class, namespace, new, void, and so on. How to determine: vs in bright blue is the keyword

• Equal judgment: = =, do not confuse with =. WriteLine ("{0}", i==1); WriteLine ("{0}", I=1), the difference. Console.WriteLine ("{0}", I=1); an assignment expression in//c# also has a value, and its value is expressed as the value of the variable after assignment • Unequal judgment:!= size comparison:<, >, <=, >= negation:! combination Operation:& & (and), | | (OR). –&&: The value of an expression is true only if both sides are true, otherwise it is false;–| | Or: The value of the expression is true if there is one on either side, or false;

Program code:

Variable:

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceVariable {classProgram {Static voidMain (string[] args) {            intA =Ten; A= One;            Console.WriteLine (a); strings ="Hello, my friend.";            Console.WriteLine (s); Charc ='a';            Console.WriteLine (c); CharC1 ='White';//Chinese characters also represent a character in C #Console.WriteLine (C1); BOOLb =true; Console.WriteLine (b);//only two evaluates to True, False//the maximum value of int, minimum valueConsole.WriteLine ("max value of int {0}, minimum value {1}",int. MaxValue,int.            MinValue);        Console.readkey (); }    }}
View Code

String

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespacestring 1{classProgram {Static voidMain (string[] args) {            //String name = "to\" M ";//If you want to output to "m, you need to use the escape character \ means you cannot take the" back "as the start or end//String name = "TO\NM";            stringName ="to\\m"; //string s = "C:\\intel\\logs";            strings =@"C:\Intel\Logs"; stringS1 =@"Sjdfjeojfla Fpelpflep";//plus @ declares multiline stringConsole.WriteLine (name);            Console.WriteLine (s);            Console.WriteLine (S1); //Data type Conversions            stringS2 ="2345"; intA =Convert.ToInt32 (S2); intb = A + -;            Console.WriteLine (b);        Console.readkey (); }    }}
View Code

Data type conversions

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespacedata type Conversion {classProgram {Static voidMain (string[] args) {Console.WriteLine ("Please enter the first number:"); stringNUM1 =Console.ReadLine (); Console.WriteLine ("Please enter a second number:"); stringnum2 =Console.ReadLine (); //Console.WriteLine (num1+num2);//This is the connection of two strings.            intI1 =Convert.ToInt32 (NUM1); intI2 =Convert.ToInt32 (num2); Console.WriteLine (I1+I2);//convert to int typeConsole.readkey (); }    }}
View Code

Exchange values for two variables

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceswaps the value of two variables {classProgram {Static voidMain (string[] args) {            intA =Ten; intb = -; Console.WriteLine ("the value of a is {1} for the value of {0},b}", A, b); inttemp =A; A=b; b=temp; Console.WriteLine ("the value of a is {1} for the value of {0},b}", A, b);        Console.readkey (); }    }}
View Code

Boolean operations

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceBoolean operation {classProgram {Static voidMain (string[] args) {            inti =5; BOOLB= (i==9);//determines if I is equal to 9, or true if equal to 9, false otherwiseb = (I! =9);//Not equal toB= (i>=9);//greater than or equal                 BOOLA =true; A= !A;            Console.WriteLine (b);            Console.WriteLine (a); intI1 =9; intI2 =-9; BOOLBool_1 = (I1 >0&& i2 >0); BOOLbool_2 = (I1 >0|| I2 >0);            Console.WriteLine (Bool_1);            Console.WriteLine (bool_2);        Console.readkey (); }    }}
View Code

Follow the video to learn C # ASP. NET the next day

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.