locked
C# help, how to find an index by item on List<> RRS feed

  • Question

  • Hello there, on this code
    Image Image01 = (Image)Image.FromFile(System.IO.Path.Com… "../../Img/Hottie01.jpg")); etc
    
    List<Image> PicList = new List<Image> { Image01, Image02, ... , Image15 }
    
    private void getPic( PictureBox value ) { //function receive and object, this objects are inside a List... and I need to know object index... }
    
    TY
    Thursday, June 20, 2013 5:45 AM

Answers

  • You need to have an object with properties.  When you are using "List&lt;&gt" on a webpage URL you are performing a search on a webpage server database and returning an html file that gets displayed.  You then need to enumerate the webpage for the returned objects which are in tags.  You can use GetElementsbyTagName() to find the objects which will give you the enumberation.  Each element may have more than one property and you can use Linq to extract items from the returned elements.

    It is similar to the code below for the generic List<> object string.

                List<string> PicList = new List<string> { "Image01", "Image02", "Image15" };
                int searchResults = PicList.IndexOf("Image02");


    jdweng

    • Marked as answer by FredNajera Thursday, June 20, 2013 9:34 AM
    Thursday, June 20, 2013 6:17 AM

All replies

  • You need to have an object with properties.  When you are using "List&lt;&gt" on a webpage URL you are performing a search on a webpage server database and returning an html file that gets displayed.  You then need to enumerate the webpage for the returned objects which are in tags.  You can use GetElementsbyTagName() to find the objects which will give you the enumberation.  Each element may have more than one property and you can use Linq to extract items from the returned elements.

    It is similar to the code below for the generic List<> object string.

                List<string> PicList = new List<string> { "Image01", "Image02", "Image15" };
                int searchResults = PicList.IndexOf("Image02");


    jdweng

    • Marked as answer by FredNajera Thursday, June 20, 2013 9:34 AM
    Thursday, June 20, 2013 6:17 AM
  • Well Done that's it! TY
    Thursday, June 20, 2013 9:34 AM