Print -
How to use C# exceptions statements
using System;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
int val = 100;
int div = 0;
int resultVal;
resultVal = (val / div);
MessageBox.Show("The result is : " + resultVal);
}
catch (System.Exception ex)
{
MessageBox.Show("Exception catch here - details : " + ex.ToString());
}
finally
{
MessageBox.Show("Enter finally block ");
}
}
}
}