Click to See Complete Forum and Search --> : [RESOLVED] [2.0] Exit and sub
shakti5385
Aug 29th, 2007, 10:41 PM
Hi all :wave:
how to exit any function or sub in C# as we use exit sub and the exit function in vb.net!
jmcilhinney
Aug 29th, 2007, 11:07 PM
You should be shot for using Exit Function in VB and you should be kicked in the shins for using Exit Sub. Good programming practice dictates that you always and only ever use a Return statement to exit a method in VB. The same is true in C#, but fortunately it's enforced because there is no other way.
Also, note that there is no such thing as a Sub or procedure in C-based languages, including C#. All methods are functions and the equivalent of a VB procedure is a function with a void return type.
shakti5385
Aug 29th, 2007, 11:57 PM
Thanks That done :bigyello:
private void button1_Click(object sender, EventArgs e)
{
Boolean b=true;
if (b==true)
{
return ;
}
MessageBox.Show("s");
}
jmcilhinney
Aug 30th, 2007, 12:26 AM
You don't return anything, which is the whole point of a void function. You just use the return statement on its own, exactly as you do in VB procedures:Private Sub SomeMethod()
Return
End Subprivate void function SomeMethod()
{
return;
}
shakti5385
Aug 30th, 2007, 12:28 AM
Thanks sir
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.