This site is 100% ad supported. Please add an exception to adblock for this site.

C# Operators

Terms

undefined, object
copy deck
List the arithmetic operators
+ -- addition
- -- subtraction
/ -- division
* -- multiplication
% -- modulo
Name the boolean operators.
& -- bitwise AND
| -- bitwise OR
^ -- bitwise OR
! -- negation
~ -- bitwise complement
&& -- logical AND
|| -- logical OR
true -- boolean constant
false -- boolean constant
What is the string concatenation operator?
+
What are the increment and decrement operators?
++ and --
What are the shift operators and what do they do?
>> shifts the argument one bit to the right.

<< shifts the argument one bit to the left.
What are the relational operators.
== -- equality
!= -- inequality
< -- less than
> -- greater than
<= -- less than or equal
>= -- greater than or equal
Name the assignment operators.
= -- assignment
+= -- addition assignment
-= -- subtraction assignment
*= -- multiplication assignment
/= -- subtraction assignment
%= -- modulo assignment
&= -- arithmetic "AND" assignment
|= -- arithmetic "OR" assignment
^= -- bitwise exclusive assignment
<<= -- shift left assignment
>>= -- shift right assignment
What is the member access operator?
.
Show the following:
index operator
cast operator
conditional operator
[]
()
?:
What operators are used to concatenate and remove delegates?
+ and - respectively.
There is a small set of operators that are used to obtain type information. What are they?
is, typeof, sizeof
In C# you can control how an application responds to an overflow exception. What are the operators that effect this control?
checked -- overflow is checked. If overflow occurs then an exception is thrown.
unchecked -- overflow is not checked. If overflow occurs execution continues and the result is truncated.
What are the indirection and address operators?
* -> [] &
The conditional operator:

What is the result of the following snippet?
int x = 4, y = 5, z = 3;

int r = (x > y)? z : z != y ? z : y;

Console.WriteLine("The value of r is {0}.", r);
The value of r is 3.
Write an equivalent to the following assignment using a different assignment operator. What is the final value of r?

int r = 5;
r = r % 2;
r %= 2;

The value of r is 1.
Which operators can be overloaded, in general? Which cannot?
The unary arithmetic, binary arithmetic and comparison operators can be overloaded.
The logical operators, the indexing operator, the cast operator, the assignment operators and, in particular, "=, ., ?:, ->, new, is, typeof, sizeof" operators cannot be overloaded.

Deck Info

16

permalink