Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经ToString()在我的 Web 服务中为我的类实现了一个覆盖方法,并List<myObject>()在消费者的函数中返回了一个。如果我这样做,.ToString()它会返回对象类型。我如何在 C# 中解决这个问题?
ToString()
List<myObject>()
.ToString()
谢谢。
在 Web 服务中来回传递对象时,它只是传递该对象公共属性的 XML 表示。任何方法,无论是否被覆盖,都不会附带它。
我建议创建一个调用 ToString() 的 StringRepresentation 属性
public string StringRepresentation { get { return this.ToString(); } set { /* Do Nothing, but there has to be a set */ } }