Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Error Handling Using Try, Catch And Finally Blocks In C#
WhatsApp
Vijayaragavan S
Aug 24
2016
4.6
k
0
0
using
System;
class
Program {
static
void
Main(
string
[] args) {
int
[] a =
new
int
[3];
int
n = args.Length;
try
{
if
(n == 0) {
int
d = 10 / (n);
}
if
(n == 1) {
a[4] = 6;
}
}
catch
(IndexOutOfRangeException e) {
Console.WriteLine(
"Exception"
+ e);
}
catch
(DivideByZeroException e) {
Console.WriteLine(
"DivideByZeroException"
+ e);
}
finally
{
Console.WriteLine(
"finally block :: End of Program"
);
}
Console.ReadKey();
}
}
Error Handling
Try
Catch
Finally Blocks
C#
Up Next
Error Handling Using Try, Catch And Finally Blocks In C#