Interesting....
There are even more approaches. One is the IsSet method where you declare an additional isSet bool to determine whether a variable has been set:
get {
_isSingle = value;
isSingeIsSet = true;
}
Another alternative is to create a custom class or enum. The thing with tri-state variables is that's it's likely that a fourth state is needed tomorrow (for example, what is null? "Unknown because you never asked", or "Unknown because it can no longer be determined" or "Unknown because they won't tell".
This may not be useful in all situation, but these situation do come up. In that case, an enum like IsSingle.True, IsSingle.False, IsSingle.WontTell might be a better option...
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to:
Korean Bodega by
Fun Lovin' Criminals (Track 4 from the album:
100% Colombian)
What's This?