Programming Journal C#, Java, SQL and to a lesser extent HTML, CSS, XML, and regex. I made this so other programmers could benefit from my experience.

Saturday, June 21, 2008

Using a nullable boolean.

It is possible to assign a nullable boolean in C#. The trick is to use ? in the declaration. Once declared, one can use the HasValue() method. An example follows:

protected void Page_Load(object sender, EventArgs e)
bool? isUser = null;
lblStatus.Text = isUser.HasValue.ToString(); //displays false
// an int example: Nullable<int> i = null;
protected void btnCheckStatus_Click(object sender, EventArgs e)
bool? isUser = false;
lblStatus.Text = isUser.HasValue.ToString(); //displays true


Anonymous said...

Hmm.. I've thought about this alot..... it sure raises a few questions..

Anonymous said...


I begin on internet with a directory

Anonymous said...

top [url=]casino[/url] brake the latest [url=]free casino bonus[/url] unshackled no deposit reward at the best [url=]free casino