1
Answer

How can implement class which derived from system.exeption?

Avi Ozer

Avi Ozer

19y
2.8k
1
I tried to implement that code:

try
{
  CheckDivideByZero(num1, num2);
}
catch (FirstDivideByZeroException)
{
  Console.WriteLine("first number is zero");
}

I need  that, FirstDivideByZeroException class will handle that Exeption instead of DevideByZeroExeption.
I tried to do that:

public  class
FirstDivideByZeroException : DivideByZeroException {}

but when i run the application, that message appear:
"An unhandled exception of type 'System.DivideByZeroException' occurred .."


How can i implement that?
Answers (1)
0
Roei Bar

Roei Bar

NA 7.8k 0 15y

hey, i would recommend you to change your work, to work with CheckedListBox
you will have a CheckedItems Property in this, and the Value is the text in it, and if you want complex Object with multiple properties, you can have an object, and on the build just do an Override on the ToString for the displayed item Text and once you run all all Checked Items, you will have the ItemId, and by ItemId you can get any property in the ListView