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
}
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:
Subscribe to:
Post Comments (Atom)
3 comments:
Hmm.. I've thought about this alot..... it sure raises a few questions..
frokostordning
Hi,
I begin on internet with a directory
top [url=http://www.001casino.com/]casino[/url] brake the latest [url=http://www.realcazinoz.com/]free casino bonus[/url] unshackled no deposit reward at the best [url=http://www.baywatchcasino.com/]free casino
[/url].
Post a Comment