Danh mục tài liệu

C# Căn Bản Toàn Tập part 8

Số trang: 4      Loại file: pdf      Dung lượng: 120.93 KB      Lượt xem: 19      Lượt tải: 0    
Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Operators Category Arithmetic Logical String concatenation Increment and decrement Bit shifting Comparison Assignment Member access (for objects and structs) Indexing (for arrays and indexers)
Nội dung trích xuất từ tài liệu:
C# Căn Bản Toàn Tập part 8OperatorsCategory OperatorArithmetic +-*/%Logical & | ^ ~ && || !String concatenation +Increment and decrement ++ --Bit shifting >Comparison == != < > =Assignment = += -= *= /= %= &= |= ^= =Member access (for objects and structs) .Indexing (for arrays and indexers) []Cast ()Conditional (the Ternary Operator) ?:Object Creation newType information sizeof (unsafe code only) is typeof asOverflow exception control checked uncheckedIndirection and Address * -> & (unsafe code only) []Câu sau đây có nghĩa là x bằng với 3:x = 3;Nếu chúng ta muốn so sánh x với một giá trị chúng ta sử dụng kí hiệu sau ==:if (x == 3)Operator ShortcutsBảng dưới đây trình bày một danh sách đầy đủ của shortcut operators có giá trị trong C#:Shortcut Operator Tương đươngx++, ++x x=x+1x--, --x x=x-1x += y x=x+yx -= y x=x–yx *= y x=x*yx /= y x=x/yx %= y x=x%yx >>= y x = x >> yx s += (x == 1 ? man : men);Console.WriteLine(s);isint i = 10;if (i is object){ Console.WriteLine(i is an object);}sizeofstring s = A string;unsafe{ Console.WriteLine(sizeof(int));}Operator PrecedenceGroup Operators () . [] x++ x-- new typeof sizeof checked uncheckedUnary + - ! ~ ++x --x and castsMultiplication/Division */%Addition/Subtraction +-Bitwise shift operators >Relational < > = is asComparison == !=Bitwise AND &Bitwise XOR ^Bitwise OR |Boolean AND &&Boolean OR ||Ternary operator ?:Assignment = += -= *= /= %= &= |= ^= = >>>=