4
Answers

How to determine if a bool variable has not been assigned a value?

wadeontheweb

wadeontheweb

20y
3.7k
1
How do I determine if a bool variable has not been assigned a value in C#? Before I set a bool variable already declared, I assume it is a value of null. What is the syntax to determine if it is null? If I do the following I get an error that I can't use "==" on a bool: bool test; if ( test == null ) { // This bool var has not been assigned yet. } Sorry for such a noob question.
Answers (4)