By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,955 Members | 1,477 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,955 IT Pros & Developers. It's quick & easy.

What is "Exit Sub" in C#?

P: n/a
What is the C# equivalent of VB.NET's Exit Sub?

Thanks,
Brett
Nov 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
return;
"Brett" <no@spam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
What is the C# equivalent of VB.NET's Exit Sub?

Thanks,
Brett

Nov 17 '05 #2

P: n/a
Nice. Thanks.

Does this mean there is no concept of a method in C#? Everything is a
function?

Brett

"Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message
news:u$**************@TK2MSFTNGP09.phx.gbl...
return;
"Brett" <no@spam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
What is the C# equivalent of VB.NET's Exit Sub?

Thanks,
Brett


Nov 17 '05 #3

P: n/a
Les
Brett,
Methods are just functions that belong to objects. You are correct, there
are just Objects and not independent functions.

"Brett" wrote:
Nice. Thanks.

Does this mean there is no concept of a method in C#? Everything is a
function?

Brett

"Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message
news:u$**************@TK2MSFTNGP09.phx.gbl...
return;
"Brett" <no@spam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
What is the C# equivalent of VB.NET's Exit Sub?

Thanks,
Brett



Nov 17 '05 #4

P: n/a
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.
}

"Brett" <no@spam.com> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
Nice. Thanks.

Does this mean there is no concept of a method in C#? Everything is a
function?

Brett

"Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message
news:u$**************@TK2MSFTNGP09.phx.gbl...
return;
"Brett" <no@spam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
What is the C# equivalent of VB.NET's Exit Sub?

Thanks,
Brett



Nov 17 '05 #5

P: n/a
Brett wrote:
What is the C# equivalent of VB.NET's Exit Sub?

Thanks,
Brett

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. :)

I suppose thats why I switched to c#.

My 2c

JB
Nov 17 '05 #6

P: n/a

"John B" <jb******@yahoo.com> wrote in message
news:42***********************@news.sunsite.dk...
Brett wrote:
What is the C# equivalent of VB.NET's Exit Sub?

Thanks,
Brett

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.


In this case, it's being used to break program flow. Not for returning
anything.

Brett
Nov 17 '05 #7

P: n/a
Brett wrote:
"John B" <jb******@yahoo.com> wrote in message
news:42***********************@news.sunsite.dk...
Brett wrote:
What is the C# equivalent of VB.NET's Exit Sub?

Thanks,
Brett


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.

In this case, it's being used to break program flow. Not for returning
anything.

Brett

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
:)
Nov 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.