Given an XElement
is there a way to find out that element's index within the parent container?
I know there must be but I just can't figure it out!
Thanks!
Try e.ElementsBeforeSelf().Count()
Try using .ToList().IndexOf()
which returns the index of the object you pass in. Example:
var index = document.Elements().ToList().IndexOf(element);
In VB
Dim Index As String = i.ToString.IndexOf(i.ToString)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.