I have a list of flag enums for input validation, I want to return one of the enums as part of my validation. So far this is what I come up with...
These are my enums.
[Flags]
public enum CheckInput
{
Not_Valid,
OK,
No_First_Name,
No_Last_Name,
No_Password,
Wrong_Password
};
This is my switch to show a message for when an enum is used
public void ValidInputSwitch()
{
CheckInput Status = CheckInput.Not_Valid;
do
{
switch (Status)
{
case CheckInput.No_First_Name:
MessageBox.Show("Please enter your first name.");
break;
case CheckInput.No_Last_Name:
MessageBox.Show("Please enter your last name.");
break;
case CheckInput.No_Password:
MessageBox.Show("Please enter your password.");
break;
case CheckInput.Wrong_Password:
MessageBox.Show("Your passwords do not match!");
break;
case CheckInput.OK:
CheckUserName(Uname);
break;
default:
break;
}
}
while (Status != CheckInput.OK);
}
Here is where my problem lies, I want to validate input and RETURN the enum so that it can run with my switch and show the message that is there
public CheckInput InputCheck
{
{
if (firstNameTxt.Text == null || firstNameTxt.Text == "") { return CheckInput.No_First_Name; }
}
}
I actually abandoned this idea in the end and used "Error Reporting". I couldn't quite get this method to work for me. Definitely due to my lack of know how. One day I'll hope to have solved the problem I had.