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. Uniqe Array

Uniqe Array

Scheduled Pinned Locked Moved C#
csharpdata-structuresquestion
7 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.
  • E Offline
    E Offline
    emran834
    wrote on last edited by
    #1

    Hello, Is not there any method available to make an Array with only Unique elements in C# ? after calling the method, the Array must get rid of all duplicate elements. Thanks Emran

    L K 3 Replies Last reply
    0
    • E emran834

      Hello, Is not there any method available to make an Array with only Unique elements in C# ? after calling the method, the Array must get rid of all duplicate elements. Thanks Emran

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Use a Hashtable.**

      How xacc.ide transforms text to colored words on the screen
      Intel PentuimM (aka Centrino) undervolting

      **

      1 Reply Last reply
      0
      • E emran834

        Hello, Is not there any method available to make an Array with only Unique elements in C# ? after calling the method, the Array must get rid of all duplicate elements. Thanks Emran

        K Offline
        K Offline
        Kevin McFarlane
        wrote on last edited by
        #3

        Have a look at the free PowerCollections library. http://www.wintellect.com/[^] You have to register to access it but registration is free and you won't get spammed! :) Oh, I'm assuming you're using .NET 2.0? Kevin

        E 1 Reply Last reply
        0
        • E emran834

          Hello, Is not there any method available to make an Array with only Unique elements in C# ? after calling the method, the Array must get rid of all duplicate elements. Thanks Emran

          K Offline
          K Offline
          Kevin McFarlane
          wrote on last edited by
          #4

          OK, I've found an example I wrote a while back using the PowerCollections library. int[] source = { 1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7, 5, 4, 4 }; List list = new List(source); list.Sort(); Algorithms.RemoveDuplicatesInPlace(list); foreach (int var in list) { Console.WriteLine(var); } Kevin

          E 1 Reply Last reply
          0
          • K Kevin McFarlane

            OK, I've found an example I wrote a while back using the PowerCollections library. int[] source = { 1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7, 5, 4, 4 }; List list = new List(source); list.Sort(); Algorithms.RemoveDuplicatesInPlace(list); foreach (int var in list) { Console.WriteLine(var); } Kevin

            E Offline
            E Offline
            emran834
            wrote on last edited by
            #5

            Hello Kevin,. Thanks for your reply. Ok, would this remove duplicate with case insensitive or case sensitive. ? Emran

            K 1 Reply Last reply
            0
            • K Kevin McFarlane

              Have a look at the free PowerCollections library. http://www.wintellect.com/[^] You have to register to access it but registration is free and you won't get spammed! :) Oh, I'm assuming you're using .NET 2.0? Kevin

              E Offline
              E Offline
              emran834
              wrote on last edited by
              #6

              Hi Kevin. Yes, I am using .NET 2.0 C# Express. Wont the code snippet work for .NET 2.0 ? Emran

              1 Reply Last reply
              0
              • E emran834

                Hello Kevin,. Thanks for your reply. Ok, would this remove duplicate with case insensitive or case sensitive. ? Emran

                K Offline
                K Offline
                Kevin McFarlane
                wrote on last edited by
                #7

                I'm away from my development PC for a couple of days. But generally these methods allow you to define a function (called a "predicate" in this context) which allows you to define the criterion for a match. Just download that library and investigate. It comes with a sample solution which demonstrates most or all of the algorithms. And re: your other reply, PowerCollections works with .NET 2.0 only, so it should work for you. There's no installation program. You just unzip the download and add a reference to the DLL. But, as I said, you do have to register at the Wintellect site (for free) to get it. When it just came out, anyone could access it. I don't know whether you've done any C++, but PowerCollections is similar in philosophy, and has similar algorithms, to the STL. Kevin

                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