CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Threaded View

  1. #1
    Join Date
    Nov 2009
    Posts
    34

    Unreachable code detected

    I can't work out what i've done wrong here, why is it telling me there is unreachable code on the "if" in this:

    Code:
    //Check email address entered is valid    
                public class RegexUtilities
                {
                public static bool IsValidEmail(string sEmailRecipient)
                    {
                    // Return true if sEmailRecipient is in valid e-mail format.
                    return Regex.IsMatch(sEmailRecipient, 
                        @"^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"); 
                    
                    if (RegexUtilities.IsValidEmail(sEmailRecipient))
                    MessageBox.Show("Valid = " + sEmailRecipient);
                              
                    else
                    MessageBox.Show("Inalid = " + sEmailRecipient);
                       }
                    
                }
    Any ideas?

    Thank you.
    Last edited by saldous; November 26th, 2009 at 07:11 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured