C # language basics 01

Source: Internet
Author: User

Console. writeline ("hello ");

Console. readkey (); // press a key to continue execution

String S = console. Readline ();//
The program is paused when the user inputs text.
You must press enter to declare a string type variable (container) s and use s to put the value returned by the Readline function.

Console. writeline (s );

/*
IntI1 = 10;
Int I2 = 20;
Console. writeline (I1 + "+ I2 +" = "+ (I1 + I2 ));
Console. writeline ("{0} + {1} = {2}", i1, I2, I1 + I2); // The placeholder starts from scratch,
The order is the order in which the second parameter of writeline starts.

Console. writeline ("{0} + {1} = {3}", i1, I2, I1 + I2); // This is incorrect.
Console. writeline ("{0} + {1} = {2}", i1, I2, I1 + I2, "AAA ");
*/There cannot be spaces between asterisks and slashes in comments of multiple lines.

Console. writeline ("Enter the boy's name ");
String boy = console. Readline ();
Console. writeline ("Enter the girl's name ");
String girl = console. Readline ();
Console. writeline ("{0} love {0}", boy, girl );
Console. readkey (); // press a key to continue execution

All interruptions: You can see where the program is interrupted


Vs Development Environment Introduction:
Solution MANAGER: solutions, projects, and files
C # source files generally end with CS
C # the entry of the program is the main function, which writes the line of code in the main, so you don't have to worry about what other parts mean.
Error List. You don't have to worry about compilation errors. Troubleshooting demo. Common Errors: there are no semicolons at the end and case-insensitive errors.
Displays the code line number.
Tool-> Option-> Text Editor-> C #-> line number

One execution from top to bottom.
Case Sensitive
Function parameters are surrounded ()
The two codes are separated by semicolons (must use English half-width symbols;
Comment: single-line comment and multi-line comment.

Variable:
Think of variables as containers for storing data
How to define variables: type variable name; int I3;
Variable type: Containers of different types have different types.
The variable cannot be different from the Data Type of the variable.
Type.
String boy = console. Readline (); // error. The variable name cannot be repeated.
Boy = console. Readline (); // yes. Instead of redefining the boy variable, the existing variable is used.

Int I = 10;
Console. writeline ("I"); // I and "I" Just look the same.

Console. readkey ();

Common data types:
String int char bool decimal byte double
Long float, etc.
The value of bool is true. False.
Why does the output use the Escape Character "\", because the default value of the compiler is
If "Start string" is encountered, "it is an end string, but if there is a \ before it, it will not be treated as a string with the starting meaning ".
'A' is Char "a" is string
String S = console. Readline ();
Problem:
String STR = console Readline ();
Console. writeline (STR );
User input a \ Nb. What is output?
Simple type conversion: Convert. tostring ()/convert. toint32 ()/tostring ().


String S = "" AB ""; // Error
String S = "\" AB \ "" ;\\ correct
Console. writeline (s );
Output: "AB"

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.