I have a project in ASP.NET Core 6.
I have the <Nullable>enable</Nullable>
setting in the project.
I have the following class:
public class ResponseResult<T>
{
public T? Result{ get; set; }
}
I can instantiate the class with a nullable or non-nullable generic parameter and the compiler does not generate a warning about it:
var a = new ResponseResult<WeatherForecast>();
var a2 = new ResponseResult<WeatherForecast?>();
My question is: why doesn't the compiler generate an error in the first case?
Since public T? Result{ get; set; }
is nullable, shouldn't I be allowed to instantiate this class only with a nullable generic parameter?