[英]What does it mean in Visual Studio debugger value “{ }”?
I have in my Visual Studio 2008 .NET C# project one property observed and debugger shows open and immediately closed curly brackets "{}". 我在我的Visual Studio 2008 .NET C#项目中观察到一个属性,调试器显示打开并立即关闭大括号“{}”。 I believe it is uninitialized (I)List, but why it does not shows "null" or "unitialized".
我相信它是未初始化的(I)List,但为什么它不显示“null”或“unitialized”。 What does "{}" it means ?
这是什么意思 ?
br, Milan. br,米兰。
The most likely reason is that the type of the value in question overrides the .ToString()
method and returns an empty string. 最可能的原因是所讨论的值的类型会覆盖
.ToString()
方法并返回空字符串。 This will cause the display to be {} as the C# EE wraps the return of .ToString inside of {}'s 这将导致显示为{},因为C#EE包含了{}内部.ToString的返回
If you want to change the value shown in the debugger you can control it with the DebuggerDisplayAttribute . 如果要更改调试器中显示的值,可以使用DebuggerDisplayAttribute控制它。 You could also override the
.ToString()
method instead. 您也可以改写
.ToString()
方法。 But this could affect other areas of your applications. 但这可能会影响您应用程序的其他区域。
This can indicate a value of System.DBNull
这可以指示
System.DBNull
的值
You can check against it like this: 您可以像这样检查它:
foreach (var val in datarow.ItemArray)
{
if (val == DBNull.Value)
{
var item = val;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.