在复杂类型链接DebuggerDisplay

编程入门 行业动态 更新时间:2024-10-26 07:40:15
本文介绍了在复杂类型链接DebuggerDisplay的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有几个类定义DebuggerDisplay属性。我想知道是否有一种方法来定义基于另一个一一DebuggerDisplay属性。如果我有以下类:

I have several classes defining the DebuggerDisplay attribute. I want to know if there is a way to define one DebuggerDisplay attribute based on another one. If I have the following classes:

[DebuggerDisplay ("Text = {Text}")] class A { public string Text {get;set;} } [DebuggerDisplay ("Property = {Property}")] class B { public A Property {get; set;} }

我想对A类,因为它是在A级DebuggerDisplay属性定义的B实例看。那相反,我得到了A类的ToString()方法到调试器,一边欣赏B类对象。

I would like to see on instances of B the A class as it is defined on the class A DebuggerDisplay attribute. Instead of that I'm getting the class A ToString() method onto the debugger while viewing class B objects.

推荐答案

不知道我是否正确地理解你的问题,但尝试:

Not sure if I understood your problem correctly but try:

[DebuggerDisplay("Property = {Property.Text}")] public class B { public A Property { get; set; } }

这将显示A的Text属性。

This will Display the A's Text property.

如果您需要更复杂的控制,你可以使用 DebuggerTypeProxyAttribute

If you need more complex control you can use DebuggerTypeProxyAttribute

更多推荐

在复杂类型链接DebuggerDisplay

本文发布于:2023-11-16 16:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605759.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类型   链接   DebuggerDisplay

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!