Hi friends,
I want to know that how will we handle exception without using try, catch and finally? Anyone give an explanation that how it is possible to do that?
Exception handling in C#
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


VulpesRank #55 · 29.2K reputationPosted Feb 13, 2012, 6:34 AM EST
http://www.c-sharpcorner.com/Forums/Thread/132543/exception-without-try-catch.aspx
Posted Feb 13, 2012, 7:09 AM EST
If error is infrequent (that is exception) you have to use try catch. Less than 30% is infrequent.
Traditional Error Handling Methods example:
using System;
public class MathErrorPreventedWithIf
{
public static void Main()
{
int num, denom, result;
DataEntry(out num, out denom);
if (denom != 0)
result = num / denom;
else
{
Console.WriteLine("Attempt to divide by 0. Denominator replaced with 1");
result = num / 1;
}
Console.WriteLine("Result is {0}", result);
}
public static void DataEntry(out int num, out int denom)
{
Console.Write("Enter a number ");
num = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter a number to divide into the first ");
denom = Convert.ToInt32(Console.ReadLine());
}
}