foreach loop...........
- by nisardotnet
I have two questions
1) my interface i have interface called IRegister and within it i have another interface called IPerson, is that right practice?
2) i have two List(IRegister, IPerson) both can have one or more rows.
what is the best way to loop both List? within GetValidationRules?
public interface IRegister
{
string FirstName { get; }
string MiddleName { get; }
string LastName { get; }
string EmailAddress { get; }
List Student { get; }
}
public static List GetValidationRules(List register)
{
List validationRules = new List();
foreach (IRegister myregister in register)
{
if (string.IsNullOrEmpty(myregister.FirstName))
validationRules.Add(new ValidationRule("Reg", "Must have aFirst Name"));
if (string.IsNullOrEmpty(myregister.LastName))
validationRules.Add(new ValidationRule("Reg", "Must have a Last Name"));
if (string.IsNullOrEmpty(myregister.EmailAddress))
validationRules.Add(new ValidationRule("Reg", "Must have a Email Address"));
IPerson here? how
}