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