0

Can someone explain me this question?

Question: int value; value = Conver.ToInt32(!("Gari" == "Kai")); Console.Write(value); My Logic: Gari = 4 Kai = 3 Value need to be converted into an integer, but here is no "value"defined specifically as an integer. So the output must be 0 Reality: //output: 1 So why and how does it work here?

27th Aug 2019, 1:05 PM
Aykut AKSAKAL
Aykut AKSAKAL - avatar
6 Antworten
+ 4
Gari == Kai 4 == 3 -> false ! false -> true Convert.ToInt32(true) -> 1 (True has a value of 1 and False has a value of 0)
27th Aug 2019, 1:29 PM
Trigger
Trigger - avatar
+ 3
Thomas Williams so, the first ! Makes it false but inside () is also false and that's why result is true and 1.. I thought inside () is false and ! Just justifies when it false.. simple but I couldn't figure it out obviously.. :/ Thanks for the help and explanation You too wet water ))) !
27th Aug 2019, 1:33 PM
Aykut AKSAKAL
Aykut AKSAKAL - avatar
+ 2
No problem, aykut. As wet water ))) said, ! means not So if something is "not false", then it has to be "true"🙃
27th Aug 2019, 1:35 PM
Trigger
Trigger - avatar
0
Well, that ! (Not) led me to think that the output would be 0.. anyway thanks for the help. Lets wait and see other comments 😅
27th Aug 2019, 1:23 PM
Aykut AKSAKAL
Aykut AKSAKAL - avatar