How can I add in field naming to a KeyValuePair in C#
<p>I have the following code:</p>

<pre><code>        var values1 = (EReferenceKey[])Enum.GetValues(typeof(EReferenceKey)); 
        var valuesWithNames = values1.Select(
            value =&gt; new {
                Value = ((int)value).ToString("00"),
                Text = Regex.Replace(value.ToString(), "([A-Z])", " $1").Trim() 
            });
</code></pre>

<p>Here's some code that was suggested on stackoverflow that can make this method generic:</p>

<pre><code>    public static IEnumerable&lt;KeyValuePair&lt;string, string&gt;&gt; GetValues2&lt;T&gt;() where T : struct {
        var t = typeof(T);
        if (!t.IsEnum)
            throw new ArgumentException("Not an enum type");
        return Enum.GetValues(t)
            .Cast&lt;T&gt;()
            .Select(x =&gt; new KeyValuePair&lt;string, string&gt;(
                ((int)Enum.ToObject(t, x)).ToString("00"), 
                Regex.Replace(x.ToString(), "([A-Z])", " $1").Trim()
                ));
    }
</code></pre>

<p>It gives me almost the same result but it's missing the naming "Value" and "Text". Can someone suggest to me how I could modify the latter code to add these and still have the results come back in order?</p>

<p>I did try doing it myself but it gave me errors when I tried to add in the "Value =" and "Text =" to the select of the generic:</p>

<p>Error   6   The name 'Value' does not exist in the current context  </p>
