troubleshooting Question

How to retrieve a specific object from a list in C# based on the value of a field

Avatar of wademi
wademi asked on
C#Visual C++.NET
10 Comments1 Solution639 ViewsLast Modified:
      I have an object call video(See video class below ) in my C# application.
      I have a list like    List<object> mylist = new List<object>();
      I have a while loop where objects are added to the list
      Video myvideo = new Video(id,path);

      I would like to include in the while loop code that checks if an object exsist based on ONLY the ID since the path may be different.
      If the ID exsist I would like to retrieve the path for that object.
      Can you show me code examples of the following:
      1. Check if object exsist with a particular ID.
      2. Get the Path value for that object based on the ID.
      3. Remove the object for that ID.
      class Video

        private string id;
        private string Path;

        public Video(string id, string Path)
            this.MyPath = Path;
            this.Myid = id;

        public string Myid
            get{return id;}
            set{ id = value;}
        public string MyPath
            get { return Path; }
            set { Path = value; }


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros