PDA

Click to See Complete Forum and Search --> : What's the equivalent of VB On Error Resume Next in C#?


vincentg
Oct 5th, 2005, 09:30 AM
What's the equivalent of VB On Error Resume Next in C#?

Thanks..

wossname
Oct 5th, 2005, 10:10 AM
There isn't one, thankfully.

vbPoet
Oct 5th, 2005, 10:27 AM
You have to try and Catch statements.

mendhak
Oct 5th, 2005, 10:37 AM
Ah, the bane of Visual Basic programming. I hope not to see it soon.

GlenW
Oct 5th, 2005, 10:41 AM
What's the equivalent of VB On Error Resume Next in C#?
Good coding!

wossname
Oct 5th, 2005, 10:43 AM
No, good code is the opposite of resume next

GlenW
Oct 5th, 2005, 10:45 AM
No, good code is the opposite of resume next
:thumb: Sorry my mistake.

deranged
Oct 6th, 2005, 02:33 PM
an example would be:

try
{
//THIS CODE WILL ATTEMPT TO EXECUTE

//Put in anything that you think might cause an error

}
catch(Exception e)
{
//THIS IS WHAT HAPPENS IF THAT CODE CAUSES AN ERROR

//It's probably the best idea to put in code that will alert the user that an error has occurred.

}

penagate
Oct 6th, 2005, 10:34 PM
Even so you should only use Try/Catch as a last resort. And resist the temptation to wrap huge blocks of code in them. Only use it where exception handling is the only way to deal with all possible outcomes.

deranged
Oct 7th, 2005, 06:49 AM
Even so you should only use Try/Catch as a last resort. And resist the temptation to wrap huge blocks of code in them. Only use it where exception handling is the only way to deal with all possible outcomes.

True, but it works great for a time that you had some user input, and you want to convert a long to an integer for example. Sometimes it'll work, sometimes it wont.