Код: Выделить всё
public static bool AnyNull(params object?[] args)
{
if (args.Any(a => IsNull(a)))
{
return true;
}
return false;
}
private static bool IsNull([NotNullWhen(false)] object? obj) => obj is null;
< /code>
e.g.
var maybeNullObj1 = source1.GetValue();
var maybeNullObj2 = source2.GetValue();
...etc
if(AnyNull(maybeNullObj1, maybeNullObj2, ...)){
return;
}
// Do something without nullable warnings
Подробнее здесь: https://stackoverflow.com/questions/797 ... ullability
Мобильная версия