이 배열은 LINQ에 있습니다. List.Count() 및 IEnumerable.Count()가 다른 결과를 반환하는 이유는 무엇입니까?
string[] colors = { "green", "brown", "blue", "red" };
과 0을 반환
var list = new List<string>(colors);
IEnumerable<string> q3 = list.Where(c => c.Length == 3);
list.Remove("red");
listBox1.Items.Add("Oh! That is : " + q3.Count());
및 기타 수익 1
var list = new List<string>(colors);
List<string> q3 = list.Where(c => c.Length == 3).ToList();
list.Remove("red");
listBox1.Items.Add("Oh! That is : " + q3.Count());
이 일이 왜이 코드? 목록과 Ienumerable 사이의 차이점은 무엇입니까?
[지연 실행] (http://blogs.msdn.com/b/charlie/archive/2007/12/09/deferred-execution.aspx)은 검색중인 용어입니다. 'Enumerable'의 많은 [LINQ 메서드] (http://msdn.microsoft.com/en-us/library/system.linq.enumerable_methods (v = vs.100) .aspx)가 지연 실행됩니다. –
[IEnumerable과 Array, IList 및 List의 차이점은 무엇입니까?] (http://stackoverflow.com/questions/764748/whats-the-difference-between-ienumerable-and-array-ilist-and-list)) – bit
@bit : 정말 그 복제본이 아닙니다. 이것은 LINQ에서 연기 된 실행에 관한 것입니다. –