vendredi 21 août 2015

Assign Conditional Statements and Regex code into another class in C#

How can i split my if-statements and my regex code into another class. I want one class for my conditional statements and one class for my regex code. I can't seem to figure it out. When i copy and past my if statements into another class i get errors. The error that I'm getting is that the program can not recognize my label.

public void Checker() 
    {


if (Regex_Static_Class.FirstNameRgex.IsMatch(FirstName_text.Text) == false)      
//First Name Validation
            {
               First_Name_label.Text = "invalid first name";     
            }
     }

 public static class Regex_Static_Class //I want to split this into a class
 {
 public static readonly Regex FirstNameRgex = new Regex("[A-Za-z]");

 }

Aucun commentaire:

Enregistrer un commentaire