I'm trying to catch an error when a value is not selected in the combobox but I cant find whats wrong. There is a CS0136 error but I'm not sure what to do to fix it!
My Code:
try
{
BooksClass.BooksArray[0, 3] = BookCondition.SelectedItem.ToString();
}
catch (Exception e)
{
MessageBox.Show("Please select an item from the list" + e);
}
Ive tried using a for loop but the System.NullReferenceException: 'Object reference not set to an instance of an object.' error comes up:
if (string.IsNullOrEmpty(BookCondition.Text))
{
MessageBox.Show("Enter a value for The Book Condition:");
}
else
{
BooksClass.BooksArray[0, 3] = BookCondition.SelectedItem.ToString();
}