调试中的局部变量 windows

Locals variables in the debug windows

我无法在 MS Visual Studio 的 Locals windows 中看到局部变量 result,所有其他变量及其类型显示得很好。

控件已经在第33行,但我没有看到第29行的效果(参考图片)

第 28 行和第 29 行的代码

let dataContractJsonSerializer = new DataContractJsonSerializer(typeof<List[]>)
let result = (dataContractJsonSerializer).ReadObject(memoryStream) :?> List[]

编辑 - 根据更多代码的请求

[<DataContract>]
type List= {
    [<field: DataMemberAttribute(Name="href") >]
    Href: string
}

服务调用

let response = request.GetResponse() :?> HttpWebResponse
use reader = new StreamReader(response.GetResponseStream())
use memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(reader.ReadToEnd()))
let result = (new DataContractJsonSerializer(typeof<List[]>)).ReadObject(memoryStream) :?> List[]

更新:优化后好像没有出现

引自https://msdn.microsoft.com/en-us/library/aa309368(v=vs.71).aspx:"The effect of the optimization is to remove the code related to variable z, which is never used. Note also that the Locals window does not contain a node for the variable z."

private void InitializeComponent() {
...
  int j = 10, k = 20, z = 0;
  for (int i = 0; i < 10; i++) {
    z = j+k;
    btnNumbers[i].Size = new Size(30, 30);
    btnNumbers[i].Click += new System.EventHandler(btnNumbersClicked);
 }
...

如果可以,请粘贴完整的代码,而不仅仅是两行。

也就是说,这对我有用。您可能从 class.

中遗漏了 DataContractsDataMember