tagged [collections]

How to get the first element of the List or Set?

How to get the first element of the List or Set? I'd like to know if I can get the first element of a list or set. Which method to use?

12 Mar at 03:20

Can .NET 4 ISet<> HashSet<> replace NHibernate Iesi.Collections ISet , HashSet?

Can .NET 4 ISet HashSet replace NHibernate Iesi.Collections ISet , HashSet? Can .NET 4 ISet HashSet replace NHibernate Iesi.Collections ISet , HashSet ? I am using Castle proxy, and NHibernate 3.0 .

Thread safe collections in .NET

Thread safe collections in .NET What is the standard nowadays when one needs a thread safe collection (e.g. Set). Do I synchronize it myself, or is there an inherently thread safe collection?

5 Jun at 12:19

How to combine two dictionaries without looping?

How to combine two dictionaries without looping? I have two dictionaries of type `` in C#. How can I copy all the contents of one Dictionary object to the other without applying a loop?

29 Apr at 14:5

Auto-initializing C# lists

Auto-initializing C# lists I am creating a new C# List (`List`). Is there a way, other than to do a loop over the list, to initialize all the starting values to 0?

24 Sep at 14:12

Is it possible to create some IGrouping object

Is it possible to create some IGrouping object I have `List>`. Is is somehow possible to add new item to this list? Or actually, is it possible to create some IGrouping object?

22 Feb at 00:50

What is the best way to iterate through a strongly-typed generic List<T>?

What is the best way to iterate through a strongly-typed generic List? What is the best way to iterate through a strongly-typed generic List in C#.NET and VB.NET?

19 Aug at 00:27

Collection was modified; enumeration operation may not execute in ArrayList

Collection was modified; enumeration operation may not execute in ArrayList I'm trying to remove an item from an `ArrayList` and I get this Exception: `Collection was modified; enumeration operation m...

4 Mar at 20:34

Have Arrays in .NET lost their significance?

Have Arrays in .NET lost their significance? For every situation that warrants the use of an array ... there is an awesome collection with benefits. Is there any specific use case for Arrays any more ...

11 Sep at 18:14

IndexOf predicate?

IndexOf predicate? I want to find the index of an element in a list maching a certain predicate, is there a better way to do it than: ?

12 Apr at 08:33

What is the best way to clone/deep copy a .NET generic Dictionary<string, T>?

What is the best way to clone/deep copy a .NET generic Dictionary? I've got a generic dictionary `Dictionary` that I would like to essentially make a Clone() of ..any suggestions.

15 Apr at 13:54

How can you reverse traverse through a C# collection?

How can you reverse traverse through a C# collection? Is it possible to have a `foreach` statement that will traverse through a Collections object in reverse order? If not a `foreach` statement, is th...

14 Apr at 13:1

How to hide some members of an interface

How to hide some members of an interface I would like to create a custom collection that implements `ICollection`. But I would like not to expose some memebers of `ICollection` like `Clear` method. Ho...

12 Mar at 19:8

Equivalent of TreeSet in Java to C#.net

Equivalent of TreeSet in Java to C#.net I have Java code containing a `TreeSet`. I want to convert the code to C#. Which equivalent collection can I use? If there is none please suggest alternatives.

15 Feb at 12:22

finding difference between two dictionaries

finding difference between two dictionaries Is there a LINQ method to find difference between two generic dictionaries? Same as in [this question](https://stackoverflow.com/questions/6007495/differenc...

23 May at 12:25

Why doesn't ConcurrentBag<T> implement ICollection<T>?

Why doesn't ConcurrentBag implement ICollection? I have a method which takes an `IList` and adds stuff to it. I would like to pass it a [ConcurrentBag](https://learn.microsoft.com/en-us/dotnet/api/sys...

What is the complexity of OrderedDictionary?

What is the complexity of OrderedDictionary? No one said that OrderedDictionary is having two copies of elements, one in a hashtable and other in a list, I can't find complexity measurements at MSDN f...

2 Apr at 07:26

Check of two list have colliding element?

Check of two list have colliding element? Is there a way to check if one list collides with another? ex:

10 Sep at 06:54

What's the role of IEnumerable<T> and why should I use it?

What's the role of IEnumerable and why should I use it? Why should I use `IEnumerable` when I can make do with...say `List`? What's the advantage of the former over the latter?

7 Jun at 14:26

Most concise way to convert a Set<T> to a List<T>

Most concise way to convert a Set to a List For example, I am currently doing this: Can you beat this ?

13 Jan at 11:7

Identify duplicates in a List

Identify duplicates in a List I have a List of type Integer eg: I would like a method to return all the duplicates eg: What is the best way to do this?

14 Sep at 10:22

ArrayList filter

ArrayList filter How can you filter out something from a Java ArrayList like if you have: 1. How are you 2. How you doing 3. Joe 4. Mike And the filter is "How" it will remove Joe and Mike.

5 Feb at 13:21

Select N random elements from a List<T> in C#

Select N random elements from a List in C# I need a quick algorithm to select 5 random elements from a generic list. For example, I'd like to get 5 random elements from a `List`.

Difference between Dictionary and Hashtable

Difference between Dictionary and Hashtable > [Why Dictionary is preferred over hashtable in C#?](https://stackoverflow.com/questions/301371/why-dictionary-is-preferred-over-hashtable-in-c) What is ...

23 May at 12:17

What sorting algorithm does the .NET framework implement

What sorting algorithm does the .NET framework implement Could anyone please advise when implementing something like IComparable in .NET what sorting algorithm does .NET use to actually sort the under...

11 May at 03:2