다음과 같은 경우가 있습니다. "Id"가있는 항목 목록이 있습니다. 특정 ID로 항목을 검색하고 해당 값을 수정하고 컬렉션 순서를 유지해야합니다. 그렇게하는 가장 좋은 방법은 무엇입니까?IEnumarable 컬렉션에서 항목을 수정하고 순서를 유지하는 방법
var collection = <some_linq_query>
collection.Where(i=>i.Id=someId).FirstOrDefault().Property = "bla";
// now collection should be the same but the item updated.
작동중인 LINQ 쿼리 란 무엇입니까? – SLaks
ToDictionary는 순서를 유지하지 않으므로 원하지 않습니다. 구문은 다음과 같습니다. 사전 result = collection.ToDictionary (x => x.Id); –