Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
C# exception handling ⚠️
Play lesson

C# tutorial for beginners 🎵 - C# exception handling ⚠️

5.0 (6)
48 learners

What you'll learn

This course includes

  • 4 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

C# exception handling tutorial example explained #C# #exception #handling using System; namespace MyFirstProgram { class Program { static void Main(string[] args) { // exception = errors that occur during execution // try = try some code that is considered "dangerous" // catch = catches and handles exceptions when they occur // finally = always executes regardless if exception is caught or not int x; int y; double result; try { Console.Write("Enter number 1: "); x = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter number 2: "); y = Convert.ToInt32(Console.ReadLine()); result = x / y; Console.WriteLine("result: " + result); } catch (FormatException e) { Console.WriteLine("Enter ONLY numbers PLEASE!"); } catch (DivideByZeroException e) { Console.WriteLine("You can't divide by zero! IDIOT!"); } catch (Exception e) { Console.WriteLine("Something went wrong!"); } finally { Console.WriteLine("Thanks for visiting!"); } Console.ReadKey(); } } }

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere