How does in the following example XElement internally store an object implementing IEnumerable<A>? Is ToString called on each of A type objects stored in this collection and the resulting value is treated as a string content ( as aXText) and is thus appended to “someString” value, or …?
class Program
{
static void Main(string[] args)
{
A[] = new A[10];
for (int i = 0; i < 10; i++)
a[i] = new A();
XElement element = new XElement("XMLElement", "someString", a);
Console.WriteLine(element);
}
}
class A { }
thank you
See http://msdn.microsoft.com/en-us/library/bb943882.aspx for an explanation what you can pass in as contents of
XDocumentsandXElementswith the constructors and methods like Add.For your
Ainstances you are right that ToString() is called and that each result of that called is appended to form the Value of a singleXTextchild node of the “XMLElement”XElementyou create.