foreach
ループの交換
IList<EmployeeSearch> empItems = new List<EmployeeSearch>();
EmployeeSearch empItem = new EmployeeSearch();
foreach (var _emp in mediaResults.results)
{
empItem.Title = _emp.title;
empItem.Desc = _emp.description;
empItems.Add(empItem);
}
次のlinq式でエラーが発生します:
empItems = from _emp in employeeResults.results
select new EmployeeSearch
{
Title = _emp.title,
Desc = _emp.description
};
エラー:
エラー 2 型 'System.Collections.Generic.IEnumerable' を 'System.Collections.Generic.IList' に暗黙的に変換できません。明示的な変換が存在します (あなたは