Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Chương 2: Core C# Programming Construct pot
PREMIUM
Số trang
65
Kích thước
781.6 KB
Định dạng
PDF
Lượt xem
1060

Chương 2: Core C# Programming Construct pot

Nội dung xem thử

Mô tả chi tiết

Hoang Anh Viet

[email protected]

HaNoi University of Technology

1

Chapter 2. Core C#

Programming Constructs

Microsoft

Objectives

“This chapter surveys the C# language syntax. I introduce you to the two

fundamental kinds of types within the CLR: value types and reference

types. This chapter also describes namespaces and how you can use them

to logically partition types and functionality within your

applications.”

2

Microsoft

Roadmap

2.1. C# Is a strongly Typed Language

2.2. Expression

2.3. Statements and Expressions

2.4. Types and Variabless

2.5. NameSpaces

2.6. Control Flows

3

Microsoft

2.1. C# Is a strongly Typed Language

 Every variable and object instance in the system is of a well-defined

type

 This enables the compiler to check that the operations to perform on

variables and object instance are valid

 It is always best to find bugs at compile time rather than run time

 Example:

• Method ComputeAvg(): computes the average of two

integers and returns the result

4

Microsoft

double ComputeAvg( int param1, int param2 )

{

return (param1 + param2) / 2.0;

}

object ComputeAvg( object param1, object param2 )

{

return ((int) param1 + (int) param2) / 2.0;

}

ComputeAvg accepts two

integers and returns a double.

If passing an instance of Apple

type, the compiler will

complain and stop

Convert objects into

integers

Passing an instance of

Apple type causes an

exception( the instance

can’t be convert into

integer

object keyword: an alias of

System.Object class

Object is not a numeric type

5

Microsoft

Roadmap

 2.1. C# Is a strongly Typed Language

 2.2. Expression

 2.3. Statements and Expressions

 2.4. Types and Variabless

 2.5. NameSpaces

 2.6. Control Flows

6

Tải ngay đi em, còn do dự, trời tối mất!