Assigning different data types to different instances of a class?
<p>Taking the following sample:</p>

<p><img src="http://i.stack.imgur.com/2kCIX.png" alt="enter image description here"></p>

<p>I want to add a property to <code>PreferenceOption</code> called <code>DataType</code> because different instances of <code>PreferenceOption</code> could be <code>bool</code> or <code>string</code> etc. </p>

<p>Is there a way to do this? If yes, how?</p>

<p>I was thinking something like <code>public ValueType DataType { get; set; }</code>, but when creating instances of <code>PreferenceOption</code> like:</p>

<pre><code>PreferenceOption WantsHouse = new PreferenceOption () { PreferenceOption = "Want House?", Weighting = Weighting.Low, Type = bool };
</code></pre>

<p>This doesn't work, but should give a good idea of what I want to do.</p>

<p>Any suggestions?</p>

<p>EDIT (ANSWER): using the selected answer below, here's what I'm now using (apologies for blurry image!):</p>

<pre><code>public enum Weighting { One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten }

public class TenantPropertyPreferenceOption&lt;T&gt;
{
    public T PreferenceOption { get; set; }
    public Weighting Weighting { get; set; }
}

public class TenantPropertyPreferenceOptions
{
    TenantPropertyPreferenceOption&lt;bool&gt; WantsHouse = new TenantPropertyPreferenceOption&lt;bool&gt; () { PreferenceOption = false, Weighting = Weighting.One };
    // ...
}
</code></pre>
