是否有可能在c#中实现如下...
对于下面的类...
public class Foo{
public int BarId{get;set;}
public string BarString{get;set;}
}
我想实现以下 XML:
<Foo>
<BarId BarString="something">123</BarId>
</Foo>
最佳答案
ArsenMkrt 是对的,但是缺少元素的内容,我建议修改版本:
class BarId
{
[XmlText()]
public int Content {get; set;}
[XmlAttribute()]
public string BarString {get; set;}
}
public class Foo{
public BarId BarId {get; set;}
}
通过这种方式,您可以获取整数形式的内容。
关于c# - .NET Xml 序列化 : Integer Element with Attribute?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3309539/