+ 4
Why do we have to use Catch and Try and in which cases
3 Antworten
+ 11
For handling checked exceptions.
+ 6
For error checking. See here:https://msdn.microsoft.com/en-us/library/hh279678.aspx
There is also throw. Which will generate an error that is passed to catch.
+ 2
as Jay said, to catch errors. Say you want to try something, like open a file, but the file doesn't exist.. instead of crashing the program, put it in a try{} and if it doesn't exist catch{} it and maybe tell the user the file doesn't exist.