我在一個類中有以下方法:public IPlayerInfo GetPlayerInfo(int playerId){ return GetPlayerDetails(playerId).Matches; // Matches have Runs and Wickets list}我有一個課程如下:public class MyClass{ public Lazy<IMyInterface> _service1; public MyClass(Lazy<IMyInterface> service1) { _serivce1 = service1; } public void SomeMethod() { var runsList = _serivce1.GetPlayerInfo(1).Runs; // debugging this line of code }}當我嘗試調試上面的代碼時,我看到了_serivce1.GetPlayerInfo(1)使用 quick watch ( Shift + F9)的價值。我擴展了它的所有子節點。它的子節點之一是Runs。我擴展了Runs。它顯示Expanding the Results View will enumerate the IEnumerable。我一一列舉。它是空的。我沒有關閉調試一段時間后,當我按下 shift + F9 并在 quick watch 中再次查看它時,它在我枚舉 IEnumerable 后添加了一項。魔法!一段時間后,當我按下 shift + F9 并在 quick watch 中再次查看它時,它在我枚舉 IEnumerable 后添加了第二個項目。魔方?。∪缓?,由于_serivce1.GetPlayerInfo(1).Runs添加了兩個項目,而不是加載_serivce1.GetPlayerInfo(1)和擴展子節點Runs,我嘗試_serivce1.GetPlayerInfo(1).Runs直接調試但它是空的 :(當我在沒有調試的情況下運行時,_serivce1.GetPlayerInfo(1).Runs(因此runsList)根本沒有項目。如果這是由于延遲執行,請告訴我。另外,請讓我知道此問題的解決方案。
- 1 回答
- 0 關注
- 219 瀏覽
添加回答
舉報
0/150
提交
取消