1.2.1c# Data types
Common data types in C # have integer int, float float, string, boolean bool,
Analogous to int in Java, float, String, Boolean
1.2.2c# variable Name
In C #, variables are declared in the same way as Java, using the following method: Access modifier data type variable name,
The variable naming convention in C # is basically the same as Java, except that the $ symbol cannot be used in C #, as follows:
1. Composition: 52 English Letters (A~Z,A~Z), 10 digits (0~9), underscore (_), other characters not included
2. Start: Only with letters or underscores
3. Cannot be used: cannot be a keyword in C #
operator in 1.2.3c#
C # provides all the common operators supported by Java, using the same way, commonly used as follows,
Arithmetic operators: +,-, * (multiply),/(except),% (remainder), + +,--
Comparison operator: >,<,>=,<=,==,!=
Conditional operator:?:
Assignment operator: =,+=,-=,*=,/=,%=
Logical operator:&& (and), | | (OR),! Non-
Note: It is important to write a comment for it when writing the code, where a variety of annotation types are available in C #, where the line comments are used//, the block annotations use the/**/(as in Java), the document comments are used with///, and the document comments start with a///line (slightly different from Java)
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 7 namespaceHellowworld8 {9 /// <summary>Ten ///This program implements the output of a message to the console One /// </summary> A /// <param name= "args" ></param> - class Program - { the //entrance to the program - Static voidMain (string[] args) - { - /*start writing code from here*/ +Console.WriteLine ("Hellow World");//output A Word to the console -Console.ReadLine ();//Pause the output display + } A } at}
View Code
1.2c# variables and operators and annotations