I have in my Visual Studio 2008 .NET C# project one property observed and debugger shows open and immediately closed curly brackets "{}". I believe it is uninitialized (I)List, but why it does not shows "null" or "unitialized". What does "{}" it means 开发者_运维百科?
br, Milan.
The most likely reason is that the type of the value in question overrides the .ToString()
method and returns an empty string. This will cause the display to be {} as the C# EE wraps the return of .ToString inside of {}'s
If you want to change the value shown in the debugger you can control it with the DebuggerDisplayAttribute. You could also override the .ToString()
method instead. But this could affect other areas of your applications.
This can indicate a value of System.DBNull
You can check against it like this:
foreach (var val in datarow.ItemArray)
{
if (val == DBNull.Value)
{
var item = val;
}
}
精彩评论