对象到字符串和副Versa(Object to string and Vice Versa)

编程入门 行业动态 更新时间:2024-10-27 13:26:02
对象到字符串和副Versa(Object to string and Vice Versa)

我想将对象转换为字符串和副Versa进程。 情况是,我们正在使用WCF DataService的WebGet方法。 这不支持将对象作为返回类型。 因此我需要将对象转换为服务器端的字符串,并将字符串转换为客户端的对象。 我不想添加[Serializable]属性,因为我可能转换的对象是第三方类,我无法序列化。 什么是最好的解决方案。

I would like to convert the object to string and Vice Versa process. The situation is, we are using WCF DataService's WebGet method. This doesn't support object as return type. for this reason i need to convert the object to string in server side and string to object at client side. I doesn't want to add [Serializable] attribute, because the object i may convert is third party class and i can't serialize. what could be the best solution.

最满意答案

我认为将第三方类转换为一些自定义xml会更好。 从字符串重新创建对象可能非常困难。

您可以在不使用[Serializable]属性的情况下将类序列化为xml:

如何使用Visual C#将对象序列化为XML

I think converting the third party class into some custom xml would be better. It might be very difficult to recreate the object from a string.

You can serialze a class to xml without using the [Serializable] attribute:

How to serialize an object to XML by using Visual C#

更多推荐

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

发布评论

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

>www.elefans.com

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