C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
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();
}
}
C#
Catch
Error Handling
Finally Blocks
Try
Up Next
Error Handling Using Try, Catch And Finally Blocks In C#