sizeof, typeof, and ? :| Operator | Description | Example | sizeof() |
Returns the size of a data type. | sizeof(int), returns 4. |
|---|---|---|
typeof() |
Returns the type of a class. | typeof(StreamReader); |
& |
Returns the address of an variable. | &a; returns actual address of the variable. |
* |
Pointer to a variable. | *a; creates pointer named 'a' to a variable. |
? : |
Conditional Expression | If Condition is true ? Then value X : Otherwise value Y |
is |
Determines whether an object is of a certain type. | If ( Ford is Car)// Checks if Ford is an object of the Car class. |
as |
Cast without raising an exception if the cast fails. | Object obj = new StringReader("Hello");
|
| Category | Operator | Associativity |
|---|---|---|
| Postfix | () [] -> . ++ - - |
Left to right |
| Unary | + - ! ~ ++ - - (type)* & sizeof |
Right to left |
| Multiplicative | * / % |
Left to right |
| Additive | + - |
Left to right |
| Shift | << >> |
Left to right |
| Relational | < <= > >= |
Left to right |
| Equality | == != |
Left to right |
| Bitwise AND | & |
Left to right |
| Bitwise XOR | ^ |
Left to right |
| Bitwise OR | | |
Left to right |
| Logical AND | && |
Left to right |
| Logical OR | || |
Left to right |
| Conditional | ?: |
Right to left |
| Assignment | = += -= *= /= %=>>= <<= &= ^= |= |
Right to left |
| Comma | , |
Left to right |
|
A man goes into the doctor and says “I think I have hearing problems.” The doctor asks “can you describe the symptoms?” and the man replies “Sure! Homer is fat and Marge has blue hair.” |