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

时间:2015-12-02 15:19:59

标签: c# visual-studio settings

你好潜在的读者

我想知道是否可以在调试时在运行时看到settingsobjet的存储值。就像你将鼠标悬停在它们之上时看到变量的价值一样。我知道我可以随时做出:

字符串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. 

如果您知道另一种查看Filelocationvalue的方法(在我的情况下),如果您能说出来,那将非常适合。

1 个答案:

答案 0 :(得分:0)

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

只需处理设置的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);
            }
        }
相关问题