Ambiguous Generic restriction T:class vs T:struct
- by Maslow
This code generates a compiler error that the member is already defined with the same parameter types.
private T GetProperty<T>(Func<Settings, T> GetFunc) where T:class
{
try
{
return GetFunc(Properties.Settings.Default);
}
catch (Exception exception)
{
SettingReadException(this,exception);
return null;
}
}
private TNullable? GetProperty<TNullable>(Func<Settings, TNullable> GetFunc) where TNullable : struct
{
try
{
return GetFunc(Properties.Settings.Default);
}
catch (Exception ex)
{
SettingReadException(this, ex);
return new Nullable<TNullable>();
}
}
Is there a clean work around?