不能踏进返回的IEnumerable℃的方法; T&GT ;? [英] Cannot step into a method returning IEnumerable<T>?

查看:99
本文介绍了不能踏进返回的IEnumerable℃的方法; T&GT ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个返回一个IEnumerable这样的方法。

I have a method that returns an IEnumerable like this..

public virtual IEnumerable<Page> ToPages(){
  // foreach logic
  yield return pages;

  // more foreach logic
  yield return otherPages;

  // etc
}

的方法似乎工作... 在某种方式。但真正令人费解的是,我不能踏进去!我把调试点周围的一切,并且调试器只是通过他们传递正确的!

The method seems to work ... in a way. But what's really baffling is that I cannot step into it! I place debugger points all around, and the debugger just passes right through them!!!

有谁知道为什么会发生?

Does anyone know why this might occur?

推荐答案

的方法不运行,直到您列举了进去。

The method isn't run until you enumerate into it.

foo.ToPages().ToList() // will enumerate and your breakpoint will be hit.

这篇关于不能踏进返回的IEnumerable℃的方法; T&GT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆