It is like comparing Apples and Bananas.
They are completely different things.
If/Else is effectively a true or false comparison of a condition.
Pseudo Code:
If (Something) is true Do Action#1
Else Do Action#2
For Example:
if (UserInput.Name = "David")
{
MessageBox.Show("Good Morning Dave");
}
else
{
MessageBox.Show("I am Sorry, I can't do that.");
}
Try/Catch is a filter that stops things that are not already catered for.
(ie It will catch all things that do not have exceptions).
Pseudo Code:
Try [This Thing]
If [This Thing] OK Then Do Something
If [This Thing] Is unknown to the System, Go to Catch.
Catch [This Thing] Do something else
For Example
try
{
rtb.LoadFile("C:/test.txt");
}
catch (System.Exception excep)
{
MessageBox.Show(excep.Message);
}
If Helpful Please Vote Up