1.2c # variables, operators, and comments,

Source: Internet
Author: User

1.2c # variables, operators, and comments,

1.2.1c # Data Type

C # common data types include integer int, float, string, Boolean bool,

Similar to int, float, String, boolean in java

1.2.2c # variable naming

The variable declaration method in c # is the same as that in java. Use the following method: access modifier data type variable name,

In c #, the variable naming rules are basically the same as those in java, except that the $ symbol cannot be used in c #. The rules are as follows:

1. Composition: 52 English letters (~ Z, ~ Z), 10 digits (0 ~ 9), underscore (_), cannot contain other characters

2. Start: it can only start with a letter or underline

3. unavailable: cannot be a keyword in c #

Operator in 1.2.3c #

C # provides all common operators supported by java in the same way. Common operators are as follows,

Arithmetic Operators: +,-, * (multiplication),/(Division), % (remainder), ++ ,--

Comparison operators:>, <, >=, <=, = ,! =

Conditional OPERATOR :? :

Assignment operator: =, + =,-=, * =,/=, % =

Logical operators: & (and), | (OR ),! (Not)

Note: It is very important to write comments when writing code. c # provides a variety of annotation types, where the line comment uses //, block annotation use/**/(same as java), document annotation use //, and each line of document annotation starts with // (slightly different from java)

1 using System; 2 using System. collections. generic; 3 using System. linq; 4 using System. text; 5 using System. threading. tasks; 6 7 namespace HellowWorld 8 {9 /// <summary> 10 // The program outputs a message to the console 11 /// </summary> 12 /// <param name = "args"> </param> 13 class Program14 {15 // program entry 16 static void Main (string [] args) 17 {18/* write code from here */19 Console. writeLine ("hellow world"); // output a sentence 20 to the Console. readLine (); // pause output display 21} 22} 23}
View Code


 

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.