Discussion :: Operators
-
Which of the following statements is correct about the C#.NET code snippet given below?
int d;
d = Convert.ToInt32( !(30 20) );
|
A.
A value 0 will be assigned to d. |
|
B.
A value 1 will be assigned to d. |
|
C.
A value -1 will be assigned to d. |
|
D.
The code reports an error. |
|
E.
The code snippet will work correctly if ! is replaced by Not. |
Answer : Option B
Explanation :
Sample Program:
bool falseFlag = false;
bool trueFlag = true;
Console.WriteLine("{0} converts to {1}.", falseFlag,
Convert.ToInt32(falseFlag));
Console.WriteLine("{0} converts to {1}.", trueFlag,
Convert.ToInt32(trueFlag));
The example displays the following output:
False converts to 0.
True converts to 1.
Be The First To Comment

Whatsapp
Facebook