foreach loop...........
Posted
by nisardotnet
on Stack Overflow
See other posts from Stack Overflow
or by nisardotnet
Published on 2010-03-17T17:37:58Z
Indexed on
2010/03/17
17:41 UTC
Read the original article
Hit count: 373
validation
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
}
© Stack Overflow or respective owner