c# 在运行时以调试模式显示设置值

c# show Settings value in debug mode at runtime

潜在读者您好

我想知道是否可以在调试运行时看到设置对象的存储值。就像您将鼠标悬停在变量上方时如何看到变量的值一样。 我知道我总是可以做到:

string a = Properties.Settings.Default.(myObjectName) 并将鼠标悬停在 a 上,但我想知道是否有更快的方法。我已经尝试 Google 但它并没有真正向我展示任何可以回答我问题的东西:(

image of the settings

(我使用的是 visualstudios 2015 和 .Net Framework 4.5.2)。

Properties.Settings.Default.FileLocation = ProfileListBox.OpenFile;
//problem: I use the Filelocation quite often in my code but have to always backtrack to see what the currently assigned value for Filelocation is. 

如果您知道另一种查看 Filelocation 值的方法(在我的例子中),如果您能告诉我将非常感谢。

我的方法可以帮助您解决问题:

通过简单地处理设置的 PropertyChanged 事件。

        void test() {
            Settings.Default.PropertyChanged += Default_PropertyChanged;
        }

        private void Default_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "MyProperty")
            {
                 var tValue = Settings.Default.PropertyValues[e.PropertyName].PropertyValue.ToString();
                 toolStripStatusLabelMessage.Text = String.Format("Property {0} changed to {1} ", e.PropertyName , tValue);
            }
        }