The following code does not compile in C# 7.3 even though it does support generics constrained to be enums:
using System;
public class Test<T> where T: Enum
{
public void Method()
{
if (!Enum.TryParse<T>("something", out var value))
throw new Exception("Oops");
}
}
My other code that uses Enum
constraints does work, so I have the right versions of everything, it just doesn't seem to be able to call another method that also is constrained to be an Enum
.
Is this a bug or did I misunderstand how this is is supposed to work.