You to can use the return instead of ExitSub in c#
From MSDN:
The return statement terminates execution of the method in which it appears and returns control to the calling method. It can also return an optional value. If the method is a void type,
the return statement can be omitted.
Sample Code
static double CalculateArea(int r)
{
double area = r * r * Math.PI;
return area;
}
See http://msdn.microsoft.com/en-us/library/d96yfwee.aspx and in particular you'll find there the "return" and "goto" statements. The later one should be very rarely used. If used too much
it likely points to some kind of code design issue.
Participant
953 Points
785 Posts
In vb.net there are the commands "Exit Sub" and "Goto".
Nov 03, 2014 12:44 PM|Philosophaie|LINK
In vb.net there are the commands "Exit Sub" and "Goto". I can not find there analogous compatriots in c#.
All-Star
50831 Points
9895 Posts
Re: In vb.net there are the commands "Exit Sub" and "Goto".
Nov 03, 2014 12:57 PM|A2H|LINK
You to can use the return instead of ExitSub in c#
From MSDN:
The return statement terminates execution of the method in which it appears and returns control to the calling method. It can also return an optional value. If the method is a void type, the return statement can be omitted.
Sample Code
You have the goto keyword in C# also.
Aje
My Blog | Dotnet Funda
Contributor
5072 Points
1661 Posts
Re: In vb.net there are the commands "Exit Sub" and "Goto".
Nov 03, 2014 12:58 PM|francissvk|LINK
exit sub - You can use return for this purpose.
goto - Exists in C# already : http://msdn.microsoft.com/en-us/library/13940fs2.aspx
All-Star
48280 Points
17982 Posts
Re: In vb.net there are the commands "Exit Sub" and "Goto".
Nov 03, 2014 01:05 PM|PatriceSc|LINK
Hi,
See http://msdn.microsoft.com/en-us/library/d96yfwee.aspx and in particular you'll find there the "return" and "goto" statements. The later one should be very rarely used. If used too much it likely points to some kind of code design issue.