Compare values from list

Hello Experts,

i have a following problem:

so far in my demonstration example (see code below)  i have a class for storing values i get from parsing an Xml file some other functions.

    class Program

        public static XDocument doc = null;
        public static string Dokument = "";

        static void Main(string[] args)

        public static List<XmlParseObject> XmlParse()

            doc = XDocument.Load(Dokument);

            var result = from c in doc.Descendants("HotSpot")
                         select new XmlParseObject()
                             Id = (int)(c.Attribute("id")),
                             x = (float)c.Attribute("x"),
                             y = (float)c.Attribute("y"),
                             z = (float)c.Attribute("z")

            List<XmlParseObject> ListResults = new List<XmlParseObject>();

            foreach (var item in result)
                ListResults.Add(new XmlParseObject() { x = item.x, y = item.y, z = item.z, Id = item.Id });

            ListResults.Add(new XmlParseObject() { x = 666f, y = 666f, z = 666f, Id = 0 });

            return ListResults;

        public static void DisplayXmlParsedObjects()
            List<XmlParseObject> results = XmlParse();

            if (results != null)
                // Enumerate through the XmlParseObject objects and displey the info 
                foreach (XmlParseObject obj in results)
                        obj.Id, obj.x, obj.y, obj.z);


    public class XmlParseObject
        public float x { get; set; }
        public float y { get; set; }
        public float z { get; set; }
        public int Id { get; set; }

Open in new window

What i am missing is a function that will be able to compare values. Lets say i have 3 entries in my List (see XML structure)

<?xml version="1.0" encoding="utf-8"?>
	 <HotSpot id="1" x="67216.14" y="-75172.24" z="-2984.153"/>
	 <HotSpot id="2" x="66326.78" y="-74404.68" z="-3172.191"/>
	 <HotSpot id="3" x="66220.13" y="-73542.97" z="-3286.478"/>

Open in new window

What funtion should do is:

Take List entry with ID=0 and compare it with ID=1 { some code }
Take List entry with ID=1 and compare it to ID=2 {come code}
Take List with ID=2 and comare to ID=2 and so on untill last node stored in list

and then repeate the loop (console y/n if u want to repeate.)

Thank you for reading and let me know if my question is unclear.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Where is the "list"? Is it the x, y, and z values?
Kyle AbrahamsSenior .Net DeveloperCommented:
Make results a member of the class.
    List<XmlParseObject> ListResults = new List<XmlParseObject>();

     public static void CompareList()
       for (int i = 0; i < ListResults.Count - 2; i++)
               XmlParseObject obj1 = results[i];
               XmlParseObject obj2 = results[i+1];
              // do your compare.
     } while(1);            //change while(1) to get the choice from the console.

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndyAinscowFreelance programmer / ConsultantCommented:
Completely off topic.
SNAG-0015.bmpHave you done anything or is my browser behaving strangely?
TagyourareitAuthor Commented:

thank you!
TagyourareitAuthor Commented:
@Kaufmed What do you mean?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.