Hi all :wave:
how to exit any function or sub in C# as we use exit sub and the exit function in vb.net!
Printable View
Hi all :wave:
how to exit any function or sub in C# as we use exit sub and the exit function in vb.net!
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.
Thanks That done :bigyello:
C# Code:
private void button1_Click(object sender, EventArgs e) { Boolean b=true; if (b==true) { return ; } MessageBox.Show("s"); }
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:VB.NET Code:
Private Sub SomeMethod() Return End SubC# Code:
private void function SomeMethod() { return; }
Thanks sir