[英]Incorrect value while debugging in Visual Studio 2015
假設我們有示例代碼(VS2015,WinForms,.Net 4.6.1):
List<int> items = new List<int>();
private async Task test(int id)
{
id = 1;
int id_real = id;
int index = items.FindIndex(x => x == id);
}
private async void button1_Click(object sender, EventArgs e)
{
await test(0);
}
怎么可能? 有趣的部分 - 它只是Visual Studio觀察者問題,運行時結果仍然正確。
現在我知道它只發生在VS2015中,並導致這種行為 - 測試方法中的最后一個字符串。
請在TOOLS-> Options-> Debugging下啟用“使用托管兼容模式”,然后重新調試您的應用程序,我認為您將在VS2013或VS2017的調試器窗口中獲得正確的結果。
更新:
即使我們可以解決此問題,我也將此問題報告給連接報告:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.