Although most of C# ’ s operators should be familiar to C and C++ developers, this section discusses the most important operators for the benefit of new programmers and Visual Basic converts, as well as to shed light on a number of the changes introduced with C#.
C# supports the operators listed in the following
| Category | Operator |
| Arithmetic | + - * / % |
| 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) | ?: |
| Delegate concatenation and removal | +, - |
| Type information | sizeof is typeof as |
| Overflow exception control | checked unchecked |
| Indirection and address | [ ] |
| Namespace alias qualifier | : : |
| Null coalescing operator | ?? |
Note that four specific operators (sizeof, *, ->, and &, given in the table below), however, are available only in unsafe code (code that is independent of C # 's type - security), "Memory Management and Pointers." It is also important to note that the sizeof operator keywords, when used with the. NET Framework 1.0 and 1.1, require unsafe mode. This is not a since the requirement. NET Framework 2.0.
| Category | Operator |
| Operator keywords | sizeof (for .NET Framework versions 1.0 and 1.1 only) |
| Operators | * - > & |
0 comments:
Post a Comment