public class A
{
[DebuggerDisplay("{DDBpp1()}")]
public byte[] Bpp = new byte[2];
public string DDBpp1()
{
return "DDBpp";
}
public string DDBpp2()
{
short result;
if (BitConverter.IsLittleEndian)
{
var bppCopy = new byte[2];
Bpp.CopyTo(bppCopy, 0);
Array.Reverse(bppCopy);
result = BitConverter.ToInt16(bppCopy, 0);
}
else
{
result = BitConverter.ToInt16(Bpp, 0);
}
return result.ToString();
}
}
我在DebuggerDisplay
属性中使用哪种方法(DDBpp1 或 DDBpp2)并不重要。调试器下的值列始终由 {byte[2]} 填充。我期望 DDBpp1() 方法的字符串“DDBpp”或 DDBpp2() 方法的短值。该问题出现在 VS15/17 社区下。
是否可以在调试器下更改显示字段值?