Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (anonymous):

This is about C# If the following code segment compiles correctly, what do you know about the variable x? if (x) Console.WriteLine("ok"); a. x is an integer variable b. x is a boolean variable c. x is greater than 0 d. none of these I'm thinking it is d. none of these since when I input this into the console I get an error since X isn't declared. I am new to programming and C# so I'm unsure of solving too many problems. Thank you to everyone who takes time to read this. I appreciate it.

ganeshie8 (ganeshie8):

question is just asking about the segment of code. so before we proceed - we need to assume here that x is declared and the segment is inside a class.

ganeshie8 (ganeshie8):

since in C# if condition only takes boolean expressions, x must be a boolean variable for the code segment to compile correctly.

OpenStudy (anonymous):

Thanks so much ganeshie8. Truly appreciate the explanation to the problem!

ganeshie8 (ganeshie8):

yw !

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!