1.2c# variables and operators and annotations

Source: Internet
Author: User

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

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.