我试图在调试时检查List<T>
的值,但是如果T
覆盖ToString()
,我得到“儿童无法评估”错误。我使用VS2017和调试Unity3D 5.6.0f项目检查覆盖时,“孩子无法评估”ToString()
示例代码:
void Start() {
//if Sphere.ToString() is commented out, the contents are displayed correctly
var obstacles = parser.ParseFile(Variables.Paths.DefaultScene).ToList();
}
//...
[System.Diagnostics.DebuggerDisplay("{ToString()}")]//with or without this attribute
public class Sphere
{
public Vector3 Center { get; set; }
public float Radius { get; set; }
public override string ToString()
{
return "[r: " + Radius + " c: " + Center + "]";
}
}
是否T
被类或结构似乎任何没有效果,DebuggerDisplay
属性同样不具有任何影响 - 列表不能无论如何都要接受检查然而,
var tmp = new Sphere();
显示tmp
的ToString()
正确。我该如何解决这个问题?
作为的问题,有无提到'DebuggerDisplay'没有任何效果都没有。试图检查清单时总会产生“儿童无法评估”。 – wondra
你有没有尝试删除ToString()并在头上添加这个? '[System.Diagnostics.DebuggerDisplay(“[r:{Radius} c:{Center}]”)]' –