Rewrite HasValue to the ?? Operators

Viewed 5387

Is it safe to rewrite the following code:

bool b = foo.bar.HasValue ? foo.bar.Value : false;

to

bool b = foo.bar.Value ?? false;

where bar is the nullable type bool?

8 Answers
Related