1. Trang chủ
  2. » Công Nghệ Thông Tin

Bài giảng lập trình c 2010 chương 1 1 đh công nghệ đồng nai

17 208 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 17
Dung lượng 619,73 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Operators Implicitly Typed Local Variables Incrementing & Decrementing Variables... -Comments 1 -A Statement is a command that performs an action, -Comments use to explain for your Co

Trang 2

Operators and Expressions

Trang 3

Operators

Implicitly Typed Local

Variables

Incrementing &

Decrementing Variables

Trang 4

-Comments

1

-A Statement is a command that performs an action,

-Comments use to explain for your Coding

How to write comments???

See next slide…

Trang 5

//Comment 1

/*

*Comment 2

*/

/*Comment 3*/

/// <summary>

/// </summary>

/// <param name=“a"></param>

/// <param name=“b"></param>

private void func1(int a,float b)

Trang 6

2

Identifiers are names use to identify the elements in

Syntax Rules:

-Only use letter, digit, underscore -An identifier must start with a letter or an underscore -C# is a case –sensitive : nTest and ntest is different identifier

Trang 7

abstract do in protected true

dynamic join set

from let value

group partial where

into select yield

Identifying Keywords

Trang 8

- A variable is storage location that holds a value It as a box in the Computer’s memory holding temporary

information.

-To easy coding:

+Don’t start an identifier with underscore

+Start name with lower case +….

Variables

3

Trang 9

How to declare variables?

Data_type NameVariable;

string strFullName;

float fValue=0,fResult;

Trang 10

Data Type Description Size(bits) Range Example

int Whole numbers 32 –231 through 231 – 1 int nSize;

(bigger range) 64 –263 through 263 – 1 long lSize;

float Floating-point numbers 32 ±1.5 × 1045 through ±3.4 × 1038 float fDelta;

double

Double-precision (more accurate) floating-point numbers

64 ±5.0 × 10−324 through ±1.7 × 10308 double dDelta;

string Sequence of characters 16 bits per character Not applicable string strName;

char Single character 16 0 through 216 – 1 char chrAns;

Trang 11

You should initialize value for variable

int nSize=0;

String strName=“”;

Trang 12

Arithmetic

Operators

5

113 and 114 are the operands

Trang 13

Not all operators are applicable to all data

types

Example:

statements:

Console.WriteLine(“Tý” - “Tèo”);

Trang 14

How to convert from String to Number Format ?

int nValue=System Int32 Parse("113");

double dValue = System.Double.Parse("3.5");

Datatype vName=System DataTypeObject Parse(“ string ”);

Trang 15

Incrementing &

Decrementing Variables

6

X++

Postfix increment

++X

Prefix increment

X Postfix decrement

X

Prefix decrement

Trang 16

Implicitly Typed Local

Variables 7

var sAny;

Error: Implicitly-typed local variables must be initialized

var number1=1;

var strAny=“tèo”;

Trang 17

END

Ngày đăng: 03/12/2015, 18:30

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm