Guys,

A challenge for us... for you I mean lol! Can anyone of you have any idea on how to make an equivalent code of On Error Resume Next of VB to C#?.

Note: Don't use a try catch

Regards,

Jireh

Recommended Answers

All 2 Replies

>Note: Don't use a try catch
Erm, why? On Error is generally considered to be a huge wart of VB, so why would you want to avoid the superior equivalent in C# and try to emulate it?

ok... you can use a try catch but what if i have 100 lines of code, you mean to say you have to try catch it in 100 times? or arrrgggghhhh! please see below sample.

private int Calculate(int x, int y)
{
     x=x+y;
     y=y-x;
     Calculate=x+y;
     return Calculate
}

My problem is we don't know what line will the error occur. suppose the error will be in x=x+y; so it will resume in y=y-x; or the error will be in y=y-x; and again it must resume in Calculate=x+y;
and please don't ask me why it must resume...Just help me to this issue please... that it must resume to next statement if there's an error...

regards,
Jireh

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.