如何实现WCF中的自定义集合类型传输
推荐于2016-02-09
展开全部
namespace Sharpnessdotnet
{
[Serializable]
[DataContract]
public class Sharpnessdotnet
{
private string name;
[DataMember]
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
}
[Serializable]
[CollectionDataContract]
[KnownType(typeof(Sharpnessdotnet))]
public class SharpnessdotentCollection : IEnumerable<Sharpnessdotnet>
{
[DataMember]
public IList<Sharpnessdotnet> List;
public SharpnessdotentCollection()
{
List = new List<Sharpnessdotnet>();
}
public void Add(Sharpnessdotnet obj)
{
List.Add(obj);
}
public IEnumerator<Sharpnessdotnet> GetEnumerator()
{
return List.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return List.GetEnumerator();
}
}
}
{
[Serializable]
[DataContract]
public class Sharpnessdotnet
{
private string name;
[DataMember]
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
}
[Serializable]
[CollectionDataContract]
[KnownType(typeof(Sharpnessdotnet))]
public class SharpnessdotentCollection : IEnumerable<Sharpnessdotnet>
{
[DataMember]
public IList<Sharpnessdotnet> List;
public SharpnessdotentCollection()
{
List = new List<Sharpnessdotnet>();
}
public void Add(Sharpnessdotnet obj)
{
List.Add(obj);
}
public IEnumerator<Sharpnessdotnet> GetEnumerator()
{
return List.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return List.GetEnumerator();
}
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询