Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool? test = null;
- // Other code that may or may not
- // give a value to test.
- if(!test.HasValue) //check for a value
- {
- // Assume that IsInitialized
- // returns either true or false.
- test = IsInitialized();
- }
- if((bool)test) //now this cast is safe
- {
- // Do something.
- }
- // Source: https://msdn.microsoft.com/en-us/library/bb384091.aspx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement