<t>This feature is finally supported in C# 7.3!<br/>
<br/>
The following snippet (from the dotnet samples) demonstrates how:<br/>
<br/>
public static Dictionary EnumNamedValues() where T : System.Enum<br/>
{<br/>
var result = new Dictionary();<br/>
var values = Enum.GetValues(typeof(T));<br/>
<br/>
foreach (int item in values)<br/>
result.Add(item, Enum.GetName(typeof(T), item));<br/>
return result;<br/>
}<br/>
<br/>
```<br/>
<br/>
Be sure to set your language version in your C# project to version 7.3.<br/>
<br/>
Original Answer below:<br/>
<br/>
I'm late to the game, but I took it as a challenge to see how it could be done. It's not possible in C# (or VB.NET, but scroll down for F#), but *is possible* in MSIL. I wrote this little....thing<br/>
<br/>
```<br/>
// license: http://www.apache.org/licenses/LICENSE-2.0.html<br/>
.assembly MyThing{}<br/>
.class public abstract sealed MyThing.Thing<br/>
extends [mscorlib]System.Object<br/>
{<br/>
.method public static !!T GetEnumFromString(string strValue,<br/>
!!T defaultValue) cil managed<br/>
{<br/>
.maxstack 2<br/>
.locals init ([0] !!T temp,<br/>
[1] !!T return_value,<br/>
[2] class [mscorlib]System.Collections.IEnumerator enumerator,<br/>
[3] class [mscorlib]System.IDisposable disposer)<br/>
// if(string.IsNullOrEmpty(strValue)) return defaultValue;<br/>
ldarg strValue<br/>
call bool [mscorlib]System.String::IsNullOrEmpty(string)<br/>
brfalse.s HASVALUE<br/>
br RETURNDEF // return default it empty<br/>
<br/>
// foreach (T item in Enum.GetValues(typeof(T)))<br/>
HASVALUE:<br/>
// Enum.GetValues.GetEnumerator()<br/>
ldtoken !!T<br/>
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)<br/>
call class [mscorlib]System.Array [mscorl<br/>
<br/>
*(Réponse tronquée)*</t>