how to emulate a radio-button like functionality inside your code
<p>I've run into an interesting question that, so far, I haven't been able to find a good convincing answer for.</p>

<p>Imagine I have a radio button on a form, the three options are:</p>

<ul>
<li>date of birth</li>
<li>number of siblings</li>
<li>name</li>
</ul>

<p>When you implement these as a radio button, you can only specify one of the three.</p>

<p>Now imagine that I actually wanted the value to be specified as well. So my form looked something like this:</p>

<ul>
<li>date of birth: yyyy/mm/dd</li>
<li>number of siblings: nn</li>
<li>name: xyz</li>
</ul>

<p>So, if I were to select the radio button 'date of birth', then I'd be able to enter a Datetime as the value, but if I were to select Name, then I'd want a string, and alas, if I wanted to select Number of Siblings, then I'd want an integer as the value.</p>

<p>I don't think this is particularly ground-breaking in form design.</p>

<p>The interesting question is, how the heck do I do this using C# code. Let me explain.</p>

<p>I have a method, and it accepts an object of type "PersonalityTrait". This PersonalityTrait object, however, can only have one of three properties set, either it has a date of birth, or it has a number of siblings or it has a name. It cannot contain 2 or more properties. How the heck do I ensure that it contains only one of three properties??</p>

<p>I thought about leaving this task to any code that uses this object to check if it has more than one property set, but I'm not sure that task should be left to the calling code. It just goes against the DRY (Don't repeat yourself) principle. Plus I don't trust the calling code to be as vigilant.</p>

<p>I thought about creating a method on that PersonalityTrait object that would validate it (by checking that only one property is set), but again, I'm not sure the calling code will call it.</p>

<p>I thought about changing the SET property method code to actually check other properties first and throw an exception if other properties were set already, but that feels like providing a checklist on a form instead of a radio-button and throwing an exception if the user selected more than one option (it's just unintuitive to the user!!).</p>

<p>If this were just a single field, I'd create an Enum and make it one of three options (Birthday, Number of Siblings or Name), but the issue is, I also want to accept a VALUE, and I want that value to be strongly-typed.</p>

<p>This seems like a Jon-Skeet type of question, LOL, I might have to review 'C# in Depth' to figure this one out. But I figured I'd post it on StackOverFlow for now!!</p>
