字符串变量名日期的行为怪异的调试器 [英] String variable name Date acts weird in debugger

查看:144
本文介绍了字符串变量名日期的行为怪异的调试器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我,为什么被调试器处理我的字符串名为变量日期日期时间对象?

Can someone tell me why is the debugger handles my string variable named Date as a DateTime object?

code:

public class HourRegistration
{
    public string Date { get; set; }
}

请参阅屏幕捕获:

输入图像的描述在这里

使用.NET Framework 4.5,VS-2015

Using .NET framework 4.5, VS-2015

谢谢!

更新:

由于减少了code,以尽可能小的,我发现明显的问题。

By reducing the code to smallest possible, I found to obvious problem.

最低限度减少code:

Minimally reduced code:

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            DoSomething();
        }

        public static void DoSomething()
        {

            DateTime Date = DateTime.ParseExact("asdasd", "dd/MM/yyyy", CultureInfo.InvariantCulture);
        }

        public class HourRegistration
        {
            public string Date { get; set; }
        }
    }
}

截图:

这是在另一个名为完全相同串上下文一个不同的变量,并且调试器显示出其他对象的细节(基于上下文)

It was a different variable in another context named exactly the same as the string, and the debugger showed the details of the other object (based on context)

推荐答案

当你正在寻找在调试模式变量的值,它的名字相匹配,而不是内存地址。

When you are looking for variable values in debugging mode, it matches by name, not by memory address.

我同意其他人,这是可以做到更好,而且我已经看到了这个问题的在previous版本(至少VS 2013)。

I agree to others, it could be done better, moreover I've seen this issue in previous versions (at least vs 2013).

这篇关于字符串变量名日期的行为怪异的调试器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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