2013-10-25 18 views
0

所以香港專業教育學院創建clientAccountNames列表創造儘可能多的條目,因爲在另一個

public IEnumerable<String> ClientAccount_Names { get; set; } 

我已經再使用的服務讓所有的userLoginRecords,並將它們存儲在model.UserLoginRecords列表

model.UserLoginRecords = _userService.GetFiltered(filter, _preferenceService.GetMaxRows(this.GetType()), null); 

我已經計算出了no。在model.UserLoginRecords列表entires

int numberOfUsers = model.UserLoginRecords.Count(); 

我再想,因爲在model.userloginrecord到了IEnumerable ClientAccount-名稱在模型中發現添加儘可能多的條目

​​

怎麼能我會在最後一部分添加儘可能多的條目嗎?

+0

空白條目?重點是什麼? – Mansfield

+0

@Mansfield,以後只覆蓋其中一部分的默認值?至少這對我來說是一個用例,最近出現了類似的問題。 – Joey

+0

所以我可以在添加條目後,我知道要添加什麼,只需要知道多少次 – John

回答

1

使用Enumerable.Range

model.ClientAccount_Names = Enumerable.Range(0, numberOfUsers) 
              .Select(r => string.Empty); 
1

你的意思是你要添加空字符串?

model.ClientAccount_Names = new List<string>(); 

然後

for(int i=0; i < numberOfUsers; i++) 
{ 
    model.ClientAccount_Names.Add(""); 
} 

應該這樣做!

相關問題