Witam.
Natknąłem się na pewien problem, którego wcześniej nie było.
Customer? customer;
BankEvent be = new BankEvent();
if (document.VatDocument.CustomerId.HasValue)
customer = await _customersReader.GetCustomerById(document.VatDocument.CustomerId.Value);
if(customer != null) // <== W tym miejscu mam błąd "'customer' may be null here. Use of unassigned local variable 'customer'"
{
be.BankNameId = customer.BankNamesId;
be.AccountNumber = customer.BankAccountNumber;
}
Dlaczego C# wymaga, abym zrobił Customer? customer = null;
? Czy mój zapis nie znaczy tego samego? Ja wiem, że 'customer' może być null w tym miejscu... Dlatego sprawdzam czy nie jest