我们如何将IList对象转换为XML并将IList对象转换为JS

我们如何将IList对象转换为XML并将IList对象转换为JS

本文介绍了我们如何将IList对象转换为XML并将IList对象转换为JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我们如何将1)IList对象转换为XML,以及2)将IList对象转换为JSON
有人可以告诉我如何完成这些任务吗?

实际问题是:

我所做的是制作一个WCF服务,该服务从数据库表中读取数据.然后我要做的是,我使用LINQ to SQL,并进入foreach循环,在该循环中,我将所有记录存储在IList对象中.
假设我在finalObject中获得了具有事件信息的Ilist对象.现在我要做的就是将其更改为XML,因为我想向客户端提供XML格式(也是JSON格式).

例子是值得赞赏的.这将使我成为C#的新手变得更容易

问候
John Smith

Hi,

How can we convert 1)IList object to XML and 2)Also IList object to JSON
Does anybody can tell me how to do these tasks?

The Actual problem is:

what I have done is made a WCF Service whichs reads the data from database table. then what i do, I use LINQ to SQL and comes into the foreach loop where I store all the records in a IList Object.
suppose I have got the Ilist Ojbect having events information in finalObject. what I have to do now is change it to XML becuase I want to provide the XML format (also JSON format) to the Clients.

Example is appreciated. it will make the things easier for me being a novice in the C#

regards
John Smith

推荐答案


[DataContract]
class MyClass {
   [DataMember]
   IList MyContainer;
   //...
}



—SA



—SA


这篇关于我们如何将IList对象转换为XML并将IList对象转换为JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 03:06