+ 7
Wrong answer in C# quizz
I think we have a new quizz in C# with wrong answer: What is the difference between these two ways of conversion? A) Convert.ToInt32(3.7) B) (int) 3.7 The answer accepted as correct is: A rounds to 3, while B rounds to 4. But if I'm not mistaken, A rounds to 4, B just cuts the remainder (no rounding), so B casts to 3. What do you think dear sololearners?
5 ответов
+ 4
I agree. Convert.int32 uses rounding to convert. (int) just removes the remainder.
A ==4. B ==3
+ 5
Great news! The answer for the quizz was corrected!
+ 3
@Sima : Yes that is true.
+ 2
I found wrong answers with every weapon I experienced yet, but I think it's because everyone can make their own quizzes
+ 2
You are right. A == 4, while B == 3. So Convert.ToInt32 method (in C# we call all functions methods, right?) rounds, while (int) just truncates decimal part of a number