C # Language Foundation (i)

Source: Internet
Author: User

Integrated development environment for Visual Studio.NET

First, the Language foundation

(i) C # project composition structure:

1. Project structure

1.1 Project suffix

. config--configuration file (store accessory parameter file)

. csproj--project files (manage file entries)

. sln--solution files (Manage projects)

. CS Source file (program code)

Note: Different suffixes represent different types of files, and these file types are seen in Solution Explorer.

1.2 Functions of four elements: name, input, output, processing.

1.3 Main function: input statement, output statement.

Static void Maid (string[] args)

{

Contents of the main function

}

Console.readkey (); Input statement

Console.ReadLine (); Input statement

Console.WriteLine (); Output statement, wrap line

Console.Write (); Output statement, do not wrap line

1.4

Namespace Consoleapplicationl namespace

Class Program

Static void Maid (string[] args) method

1.5 Use of shortcut keys

alt+→ prompt character,

Need to execute program CTRL+F5

Ctrl+k, then CTRL + C, annotate the bank

Ctrl+k, then Ctrl+u, uncomment the bank.

Shift+delete Delete a row

Ctrl+x Clipping one line

Ctrl+shift+space displays the overload when the cursor is used inside the method function brackets

1.6 Precautions

1. Three ways to annotate

Comment Line

/**/comment section

Put it on the function and annotate the function.

2. Declare multiple variables of the same type in a row separated by commas.

Example: Int A, B; (declares the type of variable, separated by commas)

3. In the same statement, you cannot declare the same variable name to be the same type two times.

Int a=4;int a=5; (Error)

4.using represents the library referenced by the program, the following SYSTRM, etc., represented as consoles these libraries are provided by. NETFramework

5. When you create a new project, a namespace is created automatically, that is, the namespace namespace

Ii. Types of data

Base data type (value type): Shaping: Byle\short\int\long

Float type: float (f,f) \double\decimal (m,m)

Character type: Char

Boolean type: BOOL

Date Time: datetime

Enum type: enum

struct type: struct

Reference type: String type: Strings

Class Type: Object all other types of the final base class, generally not, unless you want to receive and do not know why the other type

Array types: one-dimensional and multidimensional arrays, such as int[] and int[,,,,]

Collection type

Interface type: interface

Iv. C # Escape characters

\ ' single quotation mark \ ' double quotation mark \ \ counter-obliquely carry air

\a Warning (beep) \b Backspace \f page break

\ nthe line break \ n enter \ t horizontal tab \v vertical tab

V. Variables, constants

1. Naming rules for variables

1.1 Variable names consist of: letters, numbers, underscores, @, Kanji.

1.2 initials can only be used with letters, underscores, @, Kanji.

1.3 You cannot duplicate a keyword.

2. Definition of variables

Data type variable name [= value]; (value within [] can not be written)

Example: int a=1;

3. Variable name plus keyword (cannot be assigned, only value): const

Example: const int a=1;

Vi. Basic Type conversions:

1. Automatic conversion (implicit conversion)-when converting from a value type to a reference type

2. Casts (explicit conversions)-from a reference type to a value type, or from a floating-point type to an reshape.

When converting from one reference type to a value type, you must refer to the elements in the type, which can be converted to data within the capacity range of the value type, otherwise you cannot go.

Method One: Use ().

Example: int a;double b=12.3;a= (int) b;

Method Two: Use Convert.

Example: int a;float c;double b=12.3;

A=convert. ToInt32 (b);

C=convert. ToSingle (b);

Method Three: Use the parse.

Example: int a;double b=12.3;

A=int.parse (b);

C # Language Foundation (i)

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.