I have some XML that I am consuming and deserializing.
...
...
Normally:
[XmlAttribute]
(with optional name, namespace, etc) is what you are after.
However, you can't use that directly on a collection. You would need instead to have a wrapper class for Bars, with the attribute and a:
public class Foo {
public BarWrapper Bars {get;set;}
}
public class BarWrapper {
private readonly List<Bar> bars = new List<Bar>();
[XmlElement("Bar")]
public List<Bar> Items {get{return bars;}}
[XmlAttribute]
public int Baz {get;set;}
}
public class Bar {...}