我有兩個問題foreach循環
1)我的界面我有接口稱爲IRegister,在它內部我有另一個接口稱爲IPerson,這是正確的做法?
2)我有兩個列表(IRegister,IPerson)都可以有一個或多個行。
循環兩個List的最佳方式是什麼?在GetValidationRules中?
public interface IRegister
{
string FirstName { get; }
string MiddleName { get; }
string LastName { get; }
string EmailAddress { get; }
List<IPerson> Student { get; }
}
public static List<ValidationRule> GetValidationRules(List<IRegister> register)
{
List<ValidationRule> validationRules = new List<ValidationRule>();
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
}
我猜你正在談論C#,但它會很好,如果你指定的。 – FrustratedWithFormsDesigner 2010-03-17 17:40:54
plz改述你的問題。我不認爲很多人會得到這 – Midhat 2010-03-17 17:41:10
努力理解 - 你有一個註冊,如果註冊是有效的,你想創建一個人? – 2010-03-17 17:44:14