C# - Part 42 - Exception Handling | Try | Catch | Finally | Throw - Tutorial For Beginners

preview_player
Показать описание
In this video we will be learning about how to handle exceptions in C#

When executing C# code, different errors can occur: coding errors made by the programmer, errors due to wrong input, or other unforeseeable things.

When an error occurs, C# will normally stop and generate an error message. The technical term for this is: C# will throw an exception (throw an error).

Try: The try statement allows you to define a block of code to be tested for errors while it is being executed.

Catch: The catch statement allows you to define a block of code to be executed, if an error occurs in the try block.

The try and catch keywords come in pairs.

Finally: The finally statement lets you execute code, after try...catch, regardless of the result.

Throw: The throw statement allows you to create a custom error.

Standard Exceptions
System.OutOfMemoryException
System.NullReferenceException
System.InvalidCastException
System.ArrayTypeMismatchException
System.IndexOutOfRangeException
System.ArithmeticException
System.DevideByZeroException
System.OverFlowException
Рекомендации по теме