Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. finding/comparing values in arraylists

finding/comparing values in arraylists

Scheduled Pinned Locked Moved ASP.NET
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    ssbelfast
    wrote on last edited by
    #1

    I have two arraylists, each record in each arraylist has the same 2 fields Any ideas what I could code to see if the value of a field in a given row in one arraylist is the same as the value of a field in a row in the the other arraylist?

    P 1 Reply Last reply
    0
    • S ssbelfast

      I have two arraylists, each record in each arraylist has the same 2 fields Any ideas what I could code to see if the value of a field in a given row in one arraylist is the same as the value of a field in a row in the the other arraylist?

      P Offline
      P Offline
      Paddy Boyd
      wrote on last edited by
      #2

      if (((objectType)firstArr(0)).fieldName == ((objectType)secondArr(0)).fieldName)
      {
      //etc
      }

      S 1 Reply Last reply
      0
      • P Paddy Boyd

        if (((objectType)firstArr(0)).fieldName == ((objectType)secondArr(0)).fieldName)
        {
        //etc
        }

        S Offline
        S Offline
        ssbelfast
        wrote on last edited by
        #3

        I'm not understanding whats needed for object type my arrays have two fields in each record; ID number and name, both are strings. Also the only extention that the system lets me put after my arraylist name is .GetType (objectType)firstArr(0)).GetType

        E 1 Reply Last reply
        0
        • S ssbelfast

          I'm not understanding whats needed for object type my arrays have two fields in each record; ID number and name, both are strings. Also the only extention that the system lets me put after my arraylist name is .GetType (objectType)firstArr(0)).GetType

          E Offline
          E Offline
          eggsovereasy
          wrote on last edited by
          #4

          Replace objectType with the type of object you have stored in the ArrayList, or better yet if you use .NET 2.0 use List rather than ArrayList. So for example, if you have a DataRow stored in the ArrayList, do this: ArrayList arrList1, arrList2; //stuff to instantiate your arraylists if (((DataRow)arrList1[0])[0].ToString() == ((DataRow)arrList2[0])[0].ToString()) { // do stuff } But with Lists do like this: List list1, list2; //stuff to instantiate your lists if (list1[0][0].ToString() == list2[0][0].ToString()) //do stuff

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups