내 함수는 내가 브레이크 포인트를 넣어 나는 결과 노드가 항복 볼 수 있습니다 확인중단 점 수율 리턴와 방법에 트리거되지
IEnumerable<IPublishedContent> GetAllowedBlogs(IEnumerable<IPublishedContent> blogLandingNodes)
{
foreach (var node in blogLandingNodes)
{
if ("Condition")
{
var blogsToDisplay = GetPostsForBlog(node);
foreach (var blog in blogsToDisplay)
{
yield return blog;
}
}
else
{
var blogsToDisplay = GetPostsForBlog(node, catId);
foreach (var blog in blogsToDisplay)
{
yield return blog;
}
}
}
}
,하지만 난 여기에 확인
IEnumerable<IPublishedContent> posts1 = GetAllowedBlogs(node);
같다
나는 아무것도 얻지 못합니다. 내가 잘못하고있는 것은 무엇입니까?
'GetAllowedBlogs()'는 _iterator_ 만 반환합니다. 내부의 코드는 컴파일러에 의해 상태 머신으로 변환되며 iterator_를 사용하는 경우에만 실행됩니다 (예 :'posts1'에'foreach '가있는 경우). –
당신은 무엇을 "확인"하고 어떻게합니까? –
좋은 설명은 [here] (http://csharpindepth.com/Articles/Chapter6/IteratorBlockImplementation.aspx) 및 [here] (http://www.codeproject.com/Tips/359873/Csharp-Iterator)에서 찾을 수 있습니다. - 패턴 - demystified) –