我将我的dto定义为
[DataContract(Name = "Tuner", Namespace = "")]
public class TunerDto
{
[DataMember(Name = "TunerName", Order = 1)]
public string TunerName { get; set; }
}
我将返回一系列论文,这些论文将我的XML作为正文提供:
<ArrayOfTuner>
<Tuner>
<Name>Test1</Name>
</Tuner>
...
</ArrayOfTuner>
有没有办法用调谐器替换ArrayOfTuner?
答案 0 :(得分:1)
您应该将数组包装在一个类中,这样就可以添加[CollectionDataContract]
属性来修改序列化输出:
[CollectionDataContract(ItemName = "Tuner")]
public class Tuners : List<TunerDto>
{
public Tuners() { }
public Tuners(IEnumerable<TunerDto> collection) : base(collection) { }
}