2

As per title, i need to create a method in C#/.NET 4 that can jumble the order a XPathNodeIterator object. The method needs to loop though all the child items ("/*") to randomly reorder the children.

I need some help to some to get started - All i have is the method stub:

public XPathNodeIterator RandomizeXPathNodeIterator(XPathNodeIterator iterator)

Any help is appreciated! Thanks

4

1 回答 1

0

您可以将 XPathNodeIterator 迭代为:

    XPathNavigator[] positions = new XPathNavigator[iterator.Count];
    int i = 0;

    while (iterator.MoveNext())
    {
        XPathNavigator n = iterator.Current;
        positions[i] = n;

        i++;
    }

然后,打乱数组

于 2012-10-22T13:43:27.230 回答