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. list collections

list collections

Scheduled Pinned Locked Moved C#
questiontutorial
5 Posts 4 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
    Satish_S
    wrote on last edited by
    #1

    I have 2 list collections as below List1 115 100 150 List2 115 100 now i need to check both of above list and need to get answer for matched , for example : 115 100 both matched, i need to achieve this how can i do it ?

    B N P 3 Replies Last reply
    0
    • S Satish_S

      I have 2 list collections as below List1 115 100 150 List2 115 100 now i need to check both of above list and need to get answer for matched , for example : 115 100 both matched, i need to achieve this how can i do it ?

      B Offline
      B Offline
      BobJanova
      wrote on last edited by
      #2

      C# 3.5? list1.Intersect(list2)[^] (it's an extension method in System.Linq) If not, it's trivial to produce a naive implementation which will be fine for small lists:

      IList<T> Intersection<T>(ICollection<T> one, ICollection<T> two){
      IList<T> r = new List<T>();
      foreach(T t in one)
      if(two.Contains(t)) r.Add(t);
      return r;
      }

      1 Reply Last reply
      0
      • S Satish_S

        I have 2 list collections as below List1 115 100 150 List2 115 100 now i need to check both of above list and need to get answer for matched , for example : 115 100 both matched, i need to achieve this how can i do it ?

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        You've been around long enough to know and understand the forum guidelines. DON'T REPOST. You asked this same question four hours ago in the C# forum, it has nothing to do with ASP.NET. If you didn't receive an answer, wait. Don't repost.


        I know the language. I've read a book. - _Madmatt

        B 1 Reply Last reply
        0
        • N Not Active

          You've been around long enough to know and understand the forum guidelines. DON'T REPOST. You asked this same question four hours ago in the C# forum, it has nothing to do with ASP.NET. If you didn't receive an answer, wait. Don't repost.


          I know the language. I've read a book. - _Madmatt

          B Offline
          B Offline
          BobJanova
          wrote on last edited by
          #4

          I think he should delete the other one, not this one, though. C# forum is the correct place for it, the other one is misplaced (and I didn't see it there since I don't read the ASP.NET forum ;)).

          1 Reply Last reply
          0
          • S Satish_S

            I have 2 list collections as below List1 115 100 150 List2 115 100 now i need to check both of above list and need to get answer for matched , for example : 115 100 both matched, i need to achieve this how can i do it ?

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Consider using HashSet instead.

            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