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. LINQ
  4. How to make sure that collection doesn't contain a particular element?

How to make sure that collection doesn't contain a particular element?

Scheduled Pinned Locked Moved LINQ
csharplinqtutorialquestionlearning
7 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
    senglory
    wrote on last edited by
    #1

    With using of LINQ, of course.

    I V 2 Replies Last reply
    0
    • S senglory

      With using of LINQ, of course.

      I Offline
      I Offline
      Ian McCaul
      wrote on last edited by
      #2

      !CollectionName.Contains(object);

      S 1 Reply Last reply
      0
      • I Ian McCaul

        !CollectionName.Contains(object);

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

        .COntains() is not applicable in this case because of complex comparision criteria. So I need it to be done with LINQ.

        I 1 Reply Last reply
        0
        • S senglory

          .COntains() is not applicable in this case because of complex comparision criteria. So I need it to be done with LINQ.

          I Offline
          I Offline
          Ian McCaul
          wrote on last edited by
          #4

          Ahh, ok try this

          var items =
          from c in collection
          where ?? && ??
          select c;

          S 1 Reply Last reply
          0
          • I Ian McCaul

            Ahh, ok try this

            var items =
            from c in collection
            where ?? && ??
            select c;

            S Offline
            S Offline
            senglory
            wrote on last edited by
            #5

            I need to negate this expression. How to do it?

            A 1 Reply Last reply
            0
            • S senglory

              I need to negate this expression. How to do it?

              A Offline
              A Offline
              Adam Maras
              wrote on last edited by
              #6

              var items = from c in collection
              where !(?? && ??)
              select c;

              1 Reply Last reply
              0
              • S senglory

                With using of LINQ, of course.

                V Offline
                V Offline
                Vincent Blais
                wrote on last edited by
                #7

                Any?

                bool result = !collection.Any(e=> e==?? && e==?? );

                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