Код: Выделить всё
public class Program
{
public static void Main()
{
var foo = new MyNullable();
var bar = new MyNullable();
foo.Value = 5;
foo.Value = null; // cannot convert null to 'int' because it is a non-nullable value type
bar.Value = "Hello";
bar.Value = null;
}
}
public class MyNullable{
public T? Value {get; set;} = default;
}
- Почему это проблема?
- Есть ли решение?
Подробнее здесь: https://stackoverflow.com/questions/792 ... s-nullable
Мобильная версия