Not quite. In C#, there are simply methods that return values (functions in
VB) and those that don't (subs in VB). For example, the following two
procedures would be equivalent:
VB:
Public Sub DoesNothing()
Exit Sub 'Not required, but since it's what you originally asked
about... <g>
End Sub
C#:
public void DoesNothing()
{
return; // Not required here either.
}
Further to what everyone else has said, I would like to add that Exit
Sub is just a holdover from vb6 which should (my opinion) not be used as
Return (in vb.net) does the same thing and is more readable (especially
to non vb6 porgrammers).
I never liked the distinction between sub's and functions and think a
void return type is far cleaner and more readable.
Although I suppose
public function MyFunk() as void
is not that nice.
Further to what everyone else has said, I would like to add that Exit Sub
is just a holdover from vb6 which should (my opinion) not be used as
Return (in vb.net) does the same thing and is more readable (especially to
non vb6 porgrammers).
I never liked the distinction between sub's and functions and think a void
return type is far cleaner and more readable.
Which is also what return is used for.
Either
Return
(returns nothing)
or
Return value
(value)
VB.NET would (i presume) give a compile error if you tried to actually
return a value in a "sub".
JB
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.