C# Programming - Operators - Discussion
Discussion Forum : Operators - General Questions (Q.No. 6)
6.
Which of the following statements is correct about the C#.NET code snippet given below?
int d;
d = Convert.ToInt32( !(30 < 20) );
Answer: Option
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.
Discussion:
2 comments Page 1 of 1.
Afzal said:
1 decade ago
In our expression we are checking a Boolean which give us true or false say that is 30 is not less than 20 it evaluates to true and then we are converting to integer that get the value of 1.
(1)
Rohit samudra said:
1 decade ago
When we solve the expression in bracket we get 0 and notting 0 that is value false and notting it we get value true and in c# true means in integer value is one hence the true value get converted into 1 hence answer is B.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers