Привет, пытаюсь найти причину сообщения об ошибке, найденного в приведенном ниже коде, все еще новичок в изучении C#, поэтому любая помощь очень ценится:)
private static void DisplayTransaction(Transaction transaction)
{
string type = transaction.getType();
string date = transaction.getDate().ToString();
string id = transaction.getItem().getID().ToString();
string itemname = transaction.getItem().getItemName();
if(type == "add")
{
string price = transaction.getPrice().ToString();
Console.WriteLine("\t{0, -19} {1, -6} {2, -3} {3, -10} {4, -10} {5, -5}",
date,
type,
id,
itemname,
"",
price);
}
else
{
string name = transaction.getEmployee();
Console.WriteLine("\t{0, -19} {1, -6} {2, -3} {3, -10} {4, -10} {5, -5}",
date,
type,
id,
itemname,
name,
"");
}
}
Эта строка продолжает выдавать "Система". NullReferenceException: 'Ссылка на объект не установлена для экземпляра объекта.'
Software_Assignment.Transaction.getItem (...) вернул null. "
string id = transaction.getItem().getID().ToString();