On the first day, data input and output are defined as variables & #183; & #183; & #183; and variables on the first day

Source: Internet
Author: User

On the first day, data input and output define variables... and on the first day Variables

For initial application of vs2012, select c # As the language, and 4 as the framework (do not select the frontend and backend frameworks). Then, change the name and save path to the desired path.

InMainWrite code in the function, in braces.

The first is the most basic input and output: Console. WriteLine ("); // the content in the quotation marks is directly output (if Write is directly written, no line breaks will be generated .)

Console. ReadLine (); // allows you to enter the content at will and press the Enter key to end the process. It can also be used to prevent program crash.

Basic applications:

Console. WriteLine ("Broken keyboard, millions in months"); // The content in quotation marks is directly output in the window. Console. ReadLine (); // This will wait for the user to enter, end by space or enter the next line. Console. WriteLine ("the volume is grayed out, and the site is stacked"); Console. ReadLine (); Console. ReadLine (); // This is to prevent the program from flashing back, and press enter to exit.

Tens of millions of cases and punctuation marks !!!!

Next is the variableString


String a is the definition variable; (string)

A = "value" is to assign a value to a variable.

It can be written together: string a = "value"; if it is assigned to a later value, the previous value will be overwritten.

 

Perform the "+" Operation on the two string types. The result is: concatenation.

 

The two string types perform the "+" operation, and the result is concatenated.

String a = "1"; string B = "2";

Console. WriteLine ("a + B"); the output result is 12.

Defines Integer Variables. int can only define numbers for mathematical operations.

String a = "10";

Int B = int. parse (a); this can convert the string type to integer.

Variable names cannot be duplicated !!!

Variables must be defined first !!!

The following is an application with a definition of input and output;

"Enter your name:" The cursor appears in the same line, waiting for the user to enter
"Enter your gender:" cursor, waiting for user input
"Enter your age:" Same as above
"Enter your height:" Same as above
"Enter your weight:" Same as above
"-------------------- Gorgeous split line -----------------------"
Hello xxx! Your gender is "male", your age is "18", your height is "180", and your weight is "180 ".

Console. write ("enter your name:"); // directly output the content in the quotation marks String mingzi = Console. readLine (); // define the words to be typed as variables and assign them to the Console. write ("Enter your gender:"); String xingbie = Console. readLine (); Console. write ("Enter your age:"); String nianling = Console. readLine (); Console. write ("Enter your height:"); String shengao = Console. readLine (); Console. write ("Enter your weight:"); String tizhong = Console. readLine (); Console. writeLine ("----------------------------- Gorgeous split line ---------------------------- "); String nihao =" Hello! ", Xb =" your gender is "", nl = ", your age is" ", sg =" ", and your height is" ", tz = "", your weight is "; Console. writeLine (mingzi + nihao + xb + xingbie + nl + nianling + sg + shengao + tz + "+ tizhong + "". "); //" + "Is spliced

 

 

 

 

 

 

 

 

 

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.