Using finally
ธนกร ภควณิช 650710984
finally คืออะไร
C#
C# Ex1
using System;
public class GFG {
// Main Method
static public void Main()
{
// variables
int number = 4;
int divisor = 0;
// try block
// This block raise exception
try {
int output = number / divisor;
}
// catch block
// This block handle exception
catch (DivideByZeroException) {
Console.WriteLine("Not possible to divide by zero!");
}
// finally block
// This block release the
// resources of the system
// and this block always executes
finally {
Console.WriteLine("Finally Block!");
}
}
} Output
C# Ex2
Output
Java
Java Ex1
Output
Java Ex2
Output
Python
Python Ex1
Output
Python Ex2
Output
Python Ex3
Output
สรุป
Slide and Video presentation
Reference
Last updated
