开发者

Does XElement internally store an object implementing IEnumerable<A> as a string content ( thus as XText )?

开发者 https://www.devze.com 2023-03-04 19:09 出处:网络
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

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开发者_如何学C 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 XDocuments and XElements with the constructors and methods like Add. For your A instances you are right that ToString() is called and that each result of that called is appended to form the Value of a single XText child node of the "XMLElement" XElement you create.

0

精彩评论

暂无评论...
验证码 换一张
取 消