Why do we have to use Catch and Try and in which cases | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 4

Why do we have to use Catch and Try and in which cases

12th May 2017, 12:37 AM
AlkhidierAbdalla Bakhiet idriss
AlkhidierAbdalla Bakhiet idriss - avatar
3 Réponses
+ 11
For handling checked exceptions.
12th May 2017, 1:34 AM
NimWing Yuan
NimWing Yuan - avatar
+ 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.
12th May 2017, 12:39 AM
jay
jay - avatar
+ 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.
12th May 2017, 12:45 AM
LordHill
LordHill - avatar