Summary: C # variables, placeholders, and other related knowledge

Source: Internet
Author: User

The New Year has been delayed for a lot of time. I haven't sat down to study seriously for a long time. The new year is almost over, and I have to start to study officially. It took me one day to learn by video, I learned simple variables and their related input, output, and applications, and learned several basic types:

Int (integer) char (numeric) string (string type) double (double-precision floating point number) decimal (currency value type) float (floating point number ).

In the Main method, repeated variable declaration is not allowed, but repeated values can be assigned. After repeated values are assigned, the original variable value is replaced with the newly assigned value.

1. in C #, "+" has two meanings;

1. Bind a value symbol. When either side of the plus or minus sign is a character or string type, use "+" to connect the data between the two sides.

2. the plus sign in mathematics is involved in the calculation of complex data, indicating the addition operation in mathematics.

The value assignment operator = (not the equal sign in mathematics) is the lowest calculation level in C # And is executed at the end.

2. placeholders

First {0}

Second {1}

Third {2}

.......

Example: Console. WriteLine ("name {0} gender {1} age {2}", name, sex, age );

  Main(=  age = = ;              pay =             Console.WriteLine(, name, age, pay);+name,+age+);            Console.WriteLine( + name,  + age + );                                    a = ;             b = +
  Main( name =  Tel =  sex =  age = 
  Main( Pho =  type =  money = weight = ;            Console.WriteLine(

 

Console. ReadLine (); used to receive user input data. You need to define a string variable to store user variables.

String input;

Input = Console. ReadLine ();

Equivalent to string input = Console. ReadLine ();

  Main(            Console.WriteLine( input =

3. Exchange variable values

To exchange the values of two variables, you must use the third variable.

Int a = 5, B = 10;

Int c;

C = B;

B =;

A = c;

Console. WriteLine ("a = {0} B = {1}", a, B );

Console. ReadKey ();

  Main(             a =  b = ===,b,a);

 

I wrote so much, wrote a blog review, and summarized my study today. It is quite practical. All of a sudden, this kind of feeling is already a master in this field. I just got started. I think there is a series of news about it. It's really a matter of time. There's no other way, just come on.

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.