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. General Programming
  3. C#
  4. Best way to search in a List<List

Best way to search in a List<List

Scheduled Pinned Locked Moved C#
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.
  • A Offline
    A Offline
    Ajko
    wrote on last edited by
    #1

    I need to find an integer element in this 2d list and modify it.

    A G 2 Replies Last reply
    0
    • A Ajko

      I need to find an integer element in this 2d list and modify it.

      A Offline
      A Offline
      Ajko
      wrote on last edited by
      #2

      It's a list like this: List>

      L 1 Reply Last reply
      0
      • A Ajko

        It's a list like this: List>

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Not tested: list is List<List<int>>

        foreach(List<int> list2 in list)
        {
        int index = list2.IndexOf(value);
        if(index != -1)
        {
        list2[index] = newvalue;
        break;
        }
        }

        1 Reply Last reply
        0
        • A Ajko

          I need to find an integer element in this 2d list and modify it.

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Loop through the outer list, for every list loop through the inner list and look for the item.

          --- single minded; short sighted; long gone;

          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