WCF DataContract ToString函数 [英] WCF DataContract ToString function
本文介绍了WCF DataContract ToString函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以覆盖WCF DataContrat中的ToString函数吗?现在我有:
Can you override the ToString function in a WCF DataContrat? Right now I have:
[DataContract]
public class Keyword
{
public int ID { get; set; }
public string Name { get; set; }
public override string ToString()
{
return Name;
}
}
但是它似乎不起作用.反正要使它正常工作吗?
But it doesn't seem to work. Anyway to get this working?
推荐答案
也请记住,如果您同时拥有服务器和客户端,那么通常可以将共享库用于数据合同,而不是生成客户端代理.如果这样做,那么在服务器和客户端上可以使用相同的方法,因为它们是完全相同的类型.
Remember too that if you own both the server and the client, that often you can use a shared library for data contracts rather than generating a client proxy. If you do that, then you can have the same method on both the server and client as they're exactly the same type.
这篇关于WCF DataContract ToString函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文