O
OutdoorGuy
Greetings,
I'm still relatively new to C# and was wondering if there was a way to
exit a subroutine (such as "Exit Sub" in VB)? I have the code below
which performs validations. If the user fails to enter in a First name,
then I want to set the focus to the control on the form and then exit
the subroutine. Any ideas?
private void btnSubmit_Click(object sender, System.EventArgs e)
{
...
if (this.txtFirstName.Text == "")
{
MessageBox.Show("First Name is required");
this.txtFirstName.Focus();
// I then want to exit the subroutine.
}
if (Lastname == "")
{
...
Thanks in advance!
I'm still relatively new to C# and was wondering if there was a way to
exit a subroutine (such as "Exit Sub" in VB)? I have the code below
which performs validations. If the user fails to enter in a First name,
then I want to set the focus to the control on the form and then exit
the subroutine. Any ideas?
private void btnSubmit_Click(object sender, System.EventArgs e)
{
...
if (this.txtFirstName.Text == "")
{
MessageBox.Show("First Name is required");
this.txtFirstName.Focus();
// I then want to exit the subroutine.
}
if (Lastname == "")
{
...
Thanks in advance!