Support System.Enum as generic type constraint.
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
This concept has been discussed for years on the web and I just discovered that [C# 7.3](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters#enum-constraints) now supports it:
```csharp
public static Dictionary EnumNamedValues() where T : System.Enum
{
var result = new Dictionary();
var values = Enum.GetValues(typeof(T));
foreach (int item in values)
result.Add(item, Enum.GetName(typeof(T), item));
return result;
}
```
@AnthonyDGreen would you happen to know what the discussion was for supporting this in VB as well when it was planned for C#?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.