5. Arithmetic operators ( 算數運算 ) Operator name Syntax Overloadable Basic assignment a = b No Addition a + b Yes Subtraction a - b Yes Unary plus (integer promotion) + a Yes Unary minus (additive inverse) - a Yes Multiplication a * b Yes Division a / b Yes Modulo (remainder) a % b Yes Increment ++ a, a ++ Yes Decrement -- a, a -- Yes
6. Comparison operators / Relational operators ( 比較運算 ) Operator name Syntax Overloadable Equal to a == b Yes Not equal to a != b Yes Greater than a > b Yes Less than a < b Yes Greater than or equal to a >= b Yes Less than or equal to a <= b Yes
7. Logical operators ( 邏輯運算 ) Operator name Syntax Overloadable Logical negation (NOT) ! a Yes Logical AND a && b Yes Logical OR a || b Yes
8. Bitwise operators ( 位元運算 ) Operator name Syntax Overloadable Bitwise NOT ~ a Yes Bitwise AND a & b Yes Bitwise OR a | b Yes Bitwise XOR a ^ b Yes Bitwise left shift a << b Yes Bitwise right shift a >> b Yes
9. Compound-assignment operators ( 複合賦值 ) Operator name Syntax Overloadable Addition assignment a += b Yes Subtraction assignment a -= b Yes Multiplication assignment a *= b Yes Division assignment a /= b Yes Modulo assignment a %= b Yes Bitwise AND assignment a &= b Yes Bitwise OR assignment a |= b Yes Bitwise XOR assignment a ^= b Yes Bitwise left shift assignment a <<= b Yes Bitwise right shift assignment a >>= b Yes
10. Member and pointer operators ( 成員及指標 ) Operator name Syntax Overloadable Array subscript a [ b ] Yes Indirection ("variable pointed to by a ") * a No Reference ("address of a ") & a No Member b of object pointed to by a (unsafe) a -> b No Member b of object a a . b No Member pointed to by b of object pointed to by a (unsafe) a ->* b No Member pointed to by b of object a (unsafe) a .* b No
11. Other operators ( 其它 ) Operator name Syntax Overloadable Function call See Function object . a ( a1, a2 ) Yes is operator object is string No True / False true, false Yes Ternary conditional a ? b : c No Size-of sizeof (a) sizeof ( type ) No Type identification typeof (a) typeof ( type ) No Cast (implicit, explicit) ( type ) a Yes Allocate storage new type No
32. Reading or Writing Class Use Stream Abstract class that supports reading and writing bytes. BinaryReader/ BinaryWriter Read and write encoded strings and primitive datatypes to and from streams. File , FileInfo , Directory , DirectoryInfo Provide implementations for the abstract FileSystemInfo classes, including creating, moving, renaming, and deleting files and directories. FileStream For reading to and from File objects; supports random access to files. Opens files synchronously by default; supports asynchronous file access. TextReader , T ex tWriter , StringReader , S t ringWriter TextReader and TextWriter are abstract classes designed for Unicode character I/O. StringReader and StringWriter write to and from strings, allowing your input and output to be either a stream or a string.
33. Reading or Writing (cont.) Class Use BufferedStream A stream that adds buffering to another stream such as a NetworkStream . Note that FileStream has buffering built in. BufferedStreams can improve performance of the stream to which they are attached. MemoryStream A nonbuffered stream whose encapsulated data is directly accessible in memory. A MemoryStream has no backing store, and is most useful as a temporary buffer. NetworkStream A stream over a network connection.
Reference : http://msdn.microsoft.com/zh-tw/library/saxz13w4%28v=vs.80%29.aspx The stack is always used to store the following two things: The reference portion of reference-typed local variables and parameters (such as the myTextBox reference ) Value-typed local variables and method parameters (structs, as well as integer s, bool s, char s, DateTime s, etc.) The following data is stored on the heap: The content of reference-type objects. Anything structured inside a reference-type object. 只要 struct 是放在 class 裡 這個 struct 也是會被放在 Heap 而不是 Stack. struct 裡面有 class 的話, struct 會存在 Stack 裡,而其中有一個 指標指到 Heap 中 class 。 Class 裡面有 struct 的話, stack 裡只會在 class 的指標,而 struct 會存在 Heap 中的 Class 裡