Why these 2 errors and how to solve them?
Code:
public static class EnumExtension
{
public static T EnumFlagsAll<T>(this T myEnum) where T : Enum
{
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
T result = default(T);
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
result = (T)0;
foreach (T val in Enum.GetValues(typeof(T)))
{
result = result | val;
}
return result;
}
}
Also, can we remove the warning and how?
By the way: Please use new project setting: Nullable => Enable