Interface problems
Hi I'm doing a C# program for customer registrations.
I need to use an interface to validate that the user input is correct (emailaddress must contain @-sign etc) but I don't really understand how I should do.
I have a save method that should look something like this:
and Customer looks like this:
And IValidate looks like this:
That is what I have done with the interface so far.
I know I have to do something with the customer struct and add a few more methods but I have no idea how to continue.
I would really appriciate help here, this is getting on my nerves.
Hi I'm doing a C# program for customer registrations.
I need to use an interface to validate that the user input is correct (emailaddress must contain @-sign etc) but I don't really understand how I should do.
I have a save method that should look something like this:
C#:
public void newCustomer(IValidate customer)
{
FileStream file = new FileStream(fileName, FileMode.Append);
BinaryFormatter bf = new BinaryFormatter();
try
{
bf.Serialize(file, customer);
}
catch(Exception e)
{
}
finally
{
file.Close();
}
}
and Customer looks like this:
C#:
[Serializable]
public struct Customer
{
public string firstname;
public string lastname;
public string address;
public string email;
public string userID;
}
And IValidate looks like this:
C#:
public interface IValidate
{
bool validate();
}
That is what I have done with the interface so far.
I know I have to do something with the customer struct and add a few more methods but I have no idea how to continue.
I would really appriciate help here, this is getting on my nerves.