我有這樣的類如何從類列表中獲取價值?
class single_request
{
public int _time_service { get; set; }
}
而這樣的名單,我在其中添加了一些這些類的。
List<single_request> list_Srequests = new List<single_request>();
最後,我只需要從類,地處list_Srequests總結所有_time_service
。我想這樣的代碼,使用SelectMany
foreach (int time_service in list_Srequests.SelectMany(v => v._time_service))
{
total_time_SingleReq =+ time_service;
}
,但它說,有在第一線的錯誤,像try to identify explicitly
。這裏有什麼問題?如果可能的話,提供一個真正的。
'periodic_request'的外觀如何? – Muctadir
@Rocketq - 使用'Select'來代替'SelectMany'。也在答案中更新。 –