潜在读者您好
我想知道是否可以在调试运行时看到设置对象的存储值。就像您将鼠标悬停在变量上方时如何看到变量的值一样。我知道我总是可以这样做:
string a = Properties.Settings.Default.(myObjectName) 并将鼠标悬停在 a 上,但我想知道是否有更快的方法。我已经尝试过 Google,但它并没有真正向我展示任何可以回答我的问题的内容:(
(我正在使用 Visualstudio 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.
如果您知道查看文件位置值的其他方法(就我而言),如果您能告诉我,我们将非常感激。
最佳答案
我认为这种方法可以帮助您解决问题:
只需处理设置的 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);
}
}
关于c# 在运行时在 Debug模式下显示设置值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34046350/