I have this code in Java, that I used to report exceptions (throws FileNotFoundException, IOException, ClassNotFoundException).
Example:
private void functionName() throws FileNotFoundException, IOException, ClassNotFoundException{}
I need to do this in C#, how can I do that?
It's pretty simple. In C#, you can't directly use a throws statement, because there isn´t. You may want to use this code:
private void functionName(){ throw new IOException();}
This throws an IOException. As IOException being a class, you need to create a new one, with new statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With