Visual studio-c#-20160411

Source: Internet
Author: User

The four elements of a function include: name, input, output, processing

Comment by://comment only one line;/**/note a region;

namespace ConsoleApplication6---------//namespace
{

Class program---------------------------//Classes
{
static void Main (string[] args)-----------//method, no semicolon required behind
{
Console.WriteLine ("");--------------------//Output statement, wrap line

Console.Write ("");------------------------//Output statement, do not wrap

String a = Console.ReadLine ();-----------//Input statement

/* Adder */

Console.WriteLine ("Please enter a number:");
String a = Console.ReadLine ();
Console.WriteLine ("Please enter another number:");
String B = Console.ReadLine ();
Console.WriteLine (A + "+" +b+ "=" + (int). Parse (a) +int. Parse (b)));

}

}

}

Data type:

First, the basic type

Integer int can only put a finite number of digits

Short

Long

Floating-point double the default decimal number is double

Float if the decimal is to be treated as float, you need to add the f,f suffix in the back

Character Char with single quote, only one character, except for escape characters

boolean bool can only be placed in True,false code only lowercase, and do not quote

Ii. type of reference

String double quotation mark, consisting of one or more characters

Type conversions:

1, automatic conversion as long as there is no data loss situation, will automatically convert

2. Forced conversion

For numbers to be converted it is worthwhile to add parentheses to the left, and the parentheses to write the type to be turned into.

For the string to be converted to the corresponding value: use parse; int A=int. Parse ("string");

Use convert; Double d= convert.todouble (s);

Escape characters:

\ "double quotation mark \ \ backslash \ n line break \ r enter \ t horizontal tab

Visual studio-c#-20160411

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.