C # design basics

Source: Internet
Author: User

C # design basics

(i) C # project composition structure

    1. Project structure

. config---configuration file (storage configuration parameter file)

. csproj---Project files (manage file entries)

. SLN---Solution files (Manage projects)

. cs---Source file (program code)

    1. Four elements of a function

Name, input, output, processing

    1. Contents of the main function

Console.readkey (); Input statement

console.readline ();// Input Statement

Console.WriteLine ();// Output Statement

Console.WriteLine ();//Output statement

Namespace ConsoleApplication1 Namespace

Class Program

static void Main (string[] arges) method

    1. Precautions

Comments

Note: Tell the computer not to do it as a code.

1.//comment To line end, comment one line.

2./*SDFASDFASDF **/comments in the middle of the content, multiple lines.

(ii) Data types

    1. Common Key data types

Shaping: Integer type

Short Int16 2 bytes (16 digits)

Int Int32 4-byte (32-digit) value space is an integer maximum absolute value smaller than the mobile number one

Long Int64 8 bytes (64 digits)

Float Type: decimal type

Float single 4-byte assignment plus suffix F or f differs from double assignment

Double Double 8 bytes

Decimal decimal 16 byte Assignment range decimal part large so the range of assignments is not necessarily larger than the double range

Character type

Char Char 2 bytes Only one character can be placed, and only single quotation marks can be used

Boolean type Switch

BOOL Boomleam 1 bytes can only put ture or false, cannot be quoted

String Type Multiple Letter Strings

String String character Sequences to use double quotation marks

2 Escape Symbols

\ " Double quotes represents a double-quote character

\ \ counter Slash represents a backslash character "' \ '

\ r Enter (CR) To move the current position to the beginning of the bank

\ n line Break (LF) , move the current position to the beginning of the next line

\ t Horizontal Tabulation (HT) (Skip to next TAB location)

(iii) Basic type conversion

Automatic conversion: Automatic conversion If there is no data loss

Cast:

Add parentheses to the number on the left side of the converted value, and write in parentheses to be converted to that type float a= (float) 3.14

For strings:

Method One

int A=int. Parse ("string"); float b=float. Parse ("string"); double c=double. Parse ("string")

Method Two

int A=convert.  ToInt32 (a); Float B=convert. ToSingle (b);

Practice Case One

static void mainstring[] args)

{

Console.WriteLine ("Little hi: What's your name?") ");

Console.Write ("I:");

String xm = Console.ReadLine ();

Console.WriteLine ("Small hi: Oh, so you are the" +xm+ "Ah, too! , what do you like to eat? ");

Console.Write ("I:");

string sw = Console.ReadLine ();

Console.WriteLine ("Small hi: I also like to eat" +sw+ ", you can eat how much ah?) ");

Console.Write ("I:");

String sl = Console.ReadLine ();

Console.WriteLine ("Small hi: you actually eat" +sl+ ", than I eat a lot of");

Practice Case II

Console.WriteLine ("Please enter a number:");

String a = Console.ReadLine ();

Console.WriteLine ("Please enter another number:");

String B = Console.ReadLine ();

Console.WriteLine (Convert.ToInt32 (a) +convert.toint32 (b));

Console.WriteLine (int. Parse (a) + int. Parse (b));

C # design basics

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.