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. Find the not-existing element in int arrays.

Find the not-existing element in int arrays.

Scheduled Pinned Locked Moved C#
csharpdata-structureshelpquestion
8 Posts 5 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.
  • C Offline
    C Offline
    CodingLover
    wrote on last edited by
    #1

    Hi all, I've two int arrays, something like this. {41, 3, 5, 37, 59, 4} {3, 59, 4, 5, 37} As you can see 41 is not in the second array. I want to find that actually in a C# code. Basically I want to find the value which is exists only in one array. Any comments? Thanks a lot. :)

    I appreciate your help all the time... CodingLover :)

    C D P 3 Replies Last reply
    0
    • C CodingLover

      Hi all, I've two int arrays, something like this. {41, 3, 5, 37, 59, 4} {3, 59, 4, 5, 37} As you can see 41 is not in the second array. I want to find that actually in a C# code. Basically I want to find the value which is exists only in one array. Any comments? Thanks a lot. :)

      I appreciate your help all the time... CodingLover :)

      C Offline
      C Offline
      Calla
      wrote on last edited by
      #2

      There might be a simpler way, but try just to iterate through the two arrays with a nested for loop and se if the items in the first array exist in the second.

      C 1 Reply Last reply
      0
      • C CodingLover

        Hi all, I've two int arrays, something like this. {41, 3, 5, 37, 59, 4} {3, 59, 4, 5, 37} As you can see 41 is not in the second array. I want to find that actually in a C# code. Basically I want to find the value which is exists only in one array. Any comments? Thanks a lot. :)

        I appreciate your help all the time... CodingLover :)

        D Offline
        D Offline
        Dust Signs
        wrote on last edited by
        #3

        Enumerable.Except (since .NET 3.5) Dust Signs

        The number you dialed is imaginary. Please turn your phone by 90 degrees and try again

        H C 2 Replies Last reply
        0
        • D Dust Signs

          Enumerable.Except (since .NET 3.5) Dust Signs

          The number you dialed is imaginary. Please turn your phone by 90 degrees and try again

          H Offline
          H Offline
          himanshu2561
          wrote on last edited by
          #4

          :thumbsup:

          himanshu

          1 Reply Last reply
          0
          • C Calla

            There might be a simpler way, but try just to iterate through the two arrays with a nested for loop and se if the items in the first array exist in the second.

            C Offline
            C Offline
            CodingLover
            wrote on last edited by
            #5

            Actually I've look at that, have no clue about that's the best way I can take.

            I appreciate your help all the time... CodingLover :)

            1 Reply Last reply
            0
            • C CodingLover

              Hi all, I've two int arrays, something like this. {41, 3, 5, 37, 59, 4} {3, 59, 4, 5, 37} As you can see 41 is not in the second array. I want to find that actually in a C# code. Basically I want to find the value which is exists only in one array. Any comments? Thanks a lot. :)

              I appreciate your help all the time... CodingLover :)

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

              Sounds like a set operation, I'd use sets.

              1 Reply Last reply
              0
              • D Dust Signs

                Enumerable.Except (since .NET 3.5) Dust Signs

                The number you dialed is imaginary. Please turn your phone by 90 degrees and try again

                C Offline
                C Offline
                CodingLover
                wrote on last edited by
                #7

                Thanks a lot. Actually now my application have a slight change. Now all my elements are in a list. So I've two lists now. So how can I do this. Thanks :)

                I appreciate your help all the time... CodingLover :)

                D 1 Reply Last reply
                0
                • C CodingLover

                  Thanks a lot. Actually now my application have a slight change. Now all my elements are in a list. So I've two lists now. So how can I do this. Thanks :)

                  I appreciate your help all the time... CodingLover :)

                  D Offline
                  D Offline
                  Dust Signs
                  wrote on last edited by
                  #8

                  Which list are you using exactly? A generic List? As it also implements IEnumerable you should be able to use the extension methods on them equally. Dust Signs

                  The number you dialed is imaginary. Please turn your phone by 90 degrees and try again

                  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