<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>C# 411 &#187; Collections</title>
	<atom:link href="http://www.csharp411.com/category/collections/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.csharp411.com</link>
	<description>C# Information, Code, Tips and News</description>
	<lastBuildDate>Mon, 19 Jul 2010 14:56:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sort C# Array in Descending/Reverse Order</title>
		<link>http://www.csharp411.com/sort-c-array-in-descendingreverse-order/</link>
		<comments>http://www.csharp411.com/sort-c-array-in-descendingreverse-order/#comments</comments>
		<pubDate>Thu, 14 Aug 2008 14:44:57 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/sort-c-array-in-descendingreverse-order/</guid>
		<description><![CDATA[How do you sort a C# array in descending or reverse order?  A simple way is to sort the array in ascending order, then reverse it:


int[] array = new int[] { 3, 1, 4, 5, 2 };
Array.Sort&#60;int&#62;( array );
Array.Reverse( array );

Of course, this is not efficient for large arrays.
A better approach is to create a [...]


Related posts:<ol><li><a href='http://www.csharp411.com/reverse-an-array/' rel='bookmark' title='Permanent Link: Reverse an Array'>Reverse an Array</a></li><li><a href='http://www.csharp411.com/c-stable-sort/' rel='bookmark' title='Permanent Link: C# Stable Sort'>C# Stable Sort</a></li><li><a href='http://www.csharp411.com/parse-and-sort-comma-delimited-numbers/' rel='bookmark' title='Permanent Link: Parse and Sort Comma-Delimited Numbers'>Parse and Sort Comma-Delimited Numbers</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/sort-c-array-in-descendingreverse-order/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>C# Empty Enumerator</title>
		<link>http://www.csharp411.com/c-empty-enumerator/</link>
		<comments>http://www.csharp411.com/c-empty-enumerator/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 13:19:20 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/c-empty-enumerator/</guid>
		<description><![CDATA[This article provides C# code for an empty enumerator.&#160; This generic class can be used to simulate enumeration over an empty collection of any type of objects.&#160; Here is the code:

using System;
using System.Collections;
using System.Collections.Generic;

public class EmptyEnumerator&#60;T&#62; : IEnumerator&#60;T&#62;
{
    public T Current
    {
        [...]


Related posts:<ol><li><a href='http://www.csharp411.com/convert-between-generic-ienumerablet/' rel='bookmark' title='Permanent Link: Convert Between Generic IEnumerable&#60;T&#62;'>Convert Between Generic IEnumerable&#60;T&#62;</a></li><li><a href='http://www.csharp411.com/convert-generic-icollectiont/' rel='bookmark' title='Permanent Link: Convert Generic ICollection&#60;T&#62;'>Convert Generic ICollection&#60;T&#62;</a></li><li><a href='http://www.csharp411.com/find-the-root-of-a-c-hierarchy/' rel='bookmark' title='Permanent Link: Find the Root of a C# Hierarchy'>Find the Root of a C# Hierarchy</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/c-empty-enumerator/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Multiple Generic IEnumerable&lt;T&gt;</title>
		<link>http://www.csharp411.com/multiple-generic-ienumerablet/</link>
		<comments>http://www.csharp411.com/multiple-generic-ienumerablet/#comments</comments>
		<pubDate>Wed, 28 May 2008 19:28:04 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/multiple-generic-ienumerablet/</guid>
		<description><![CDATA[It's possible to provide multiple generic enumerators for a single class.&#160; The trick is that clients must specify which enumerator to use.

For example, here is a "MyNumbers" class with multiple generic enumerators (in this case, for custom class "MyInt" and integer):
public class MyNumbers
    : IEnumerable&#60;MyInt&#62;, IEnumerable&#60;int&#62;

To enumerate through the class, you must [...]


Related posts:<ol><li><a href='http://www.csharp411.com/convert-generic-icollectiont/' rel='bookmark' title='Permanent Link: Convert Generic ICollection&#60;T&#62;'>Convert Generic ICollection&#60;T&#62;</a></li><li><a href='http://www.csharp411.com/convert-between-generic-ienumerablet/' rel='bookmark' title='Permanent Link: Convert Between Generic IEnumerable&#60;T&#62;'>Convert Between Generic IEnumerable&#60;T&#62;</a></li><li><a href='http://www.csharp411.com/c-empty-enumerator/' rel='bookmark' title='Permanent Link: C# Empty Enumerator'>C# Empty Enumerator</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/multiple-generic-ienumerablet/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Enumerate Collections without Exceptions</title>
		<link>http://www.csharp411.com/enumerate-collections-without-exceptions/</link>
		<comments>http://www.csharp411.com/enumerate-collections-without-exceptions/#comments</comments>
		<pubDate>Tue, 06 May 2008 13:35:25 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Threading]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/enumerate-collections-without-exceptions/</guid>
		<description><![CDATA[It's important to note that an enumerator does not have exclusive, thread-safe access to its collection.&#160; Even when a collection is synchronized, other threads can still modify the collection.&#160; Therefore, a collection's contents can change while enumerating through it, which will cause the enumerator to throw an exception.&#160; So there are three key ways to [...]


Related posts:<ol><li><a href='http://www.csharp411.com/grow-your-own-syncroot/' rel='bookmark' title='Permanent Link: Grow Your Own SyncRoot'>Grow Your Own SyncRoot</a></li><li><a href='http://www.csharp411.com/exceptions-are-for-exceptions/' rel='bookmark' title='Permanent Link: Exceptions are for Exceptions'>Exceptions are for Exceptions</a></li><li><a href='http://www.csharp411.com/c-empty-enumerator/' rel='bookmark' title='Permanent Link: C# Empty Enumerator'>C# Empty Enumerator</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/enumerate-collections-without-exceptions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Grow Your Own SyncRoot</title>
		<link>http://www.csharp411.com/grow-your-own-syncroot/</link>
		<comments>http://www.csharp411.com/grow-your-own-syncroot/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 16:18:22 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Threading]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[ArrayList]]></category>
		<category><![CDATA[Multithreading]]></category>
		<category><![CDATA[SyncRoot]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/grow-your-own-syncroot/</guid>
		<description><![CDATA[Multi-threaded code is challenging to get right and even harder to debug once it's gone wrong.  This is especially true when attempting to collect data from multiple threads.  To make this easier, many .NET collection classes include the SyncRoot property to maintain proper synchronization with other threads that might be simultaneously modifying the [...]


Related posts:<ol><li><a href='http://www.csharp411.com/enumerate-collections-without-exceptions/' rel='bookmark' title='Permanent Link: Enumerate Collections without Exceptions'>Enumerate Collections without Exceptions</a></li><li><a href='http://www.csharp411.com/manipulating-controls-across-threads/' rel='bookmark' title='Permanent Link: Manipulating Controls Across Threads'>Manipulating Controls Across Threads</a></li><li><a href='http://www.csharp411.com/constructor-chaining/' rel='bookmark' title='Permanent Link: Constructor Chaining'>Constructor Chaining</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/grow-your-own-syncroot/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Reverse an Array</title>
		<link>http://www.csharp411.com/reverse-an-array/</link>
		<comments>http://www.csharp411.com/reverse-an-array/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 15:49:00 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/reverse-an-array/</guid>
		<description><![CDATA[It's easy to reverse the contents of an array using C# generics:


static T[] ReverseArray&#60;T&#62;( T[] array )
{
    T[] newArray = null;
    int count = array == null ? 0 : array.Length;
    if (count &#62; 0)
    {
        [...]


Related posts:<ol><li><a href='http://www.csharp411.com/sort-c-array-in-descendingreverse-order/' rel='bookmark' title='Permanent Link: Sort C# Array in Descending/Reverse Order'>Sort C# Array in Descending/Reverse Order</a></li><li><a href='http://www.csharp411.com/c-empty-enumerator/' rel='bookmark' title='Permanent Link: C# Empty Enumerator'>C# Empty Enumerator</a></li><li><a href='http://www.csharp411.com/parse-and-sort-comma-delimited-numbers/' rel='bookmark' title='Permanent Link: Parse and Sort Comma-Delimited Numbers'>Parse and Sort Comma-Delimited Numbers</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/reverse-an-array/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Convert Generic ICollection&lt;T&gt;</title>
		<link>http://www.csharp411.com/convert-generic-icollectiont/</link>
		<comments>http://www.csharp411.com/convert-generic-icollectiont/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 14:21:44 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Generics-Variance]]></category>
		<category><![CDATA[ICollection]]></category>

		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/convert-generic-icollectiont/</guid>
		<description><![CDATA[As discussed in a previous article, Generics provides the ability to create strongly-typed collections in C#.  Unfortunately, C# currently does not support generics variance, which would allow inheritance of generic types.

Generics Variance: Not Allowed
For example, imagine two classes:

public class A {}
public class B : A {}

Now imagine two generic List collections and ICollection interfaces:

List&#60;A&#62; [...]


Related posts:<ol><li><a href='http://www.csharp411.com/convert-between-generic-ienumerablet/' rel='bookmark' title='Permanent Link: Convert Between Generic IEnumerable&#60;T&#62;'>Convert Between Generic IEnumerable&#60;T&#62;</a></li><li><a href='http://www.csharp411.com/c-empty-enumerator/' rel='bookmark' title='Permanent Link: C# Empty Enumerator'>C# Empty Enumerator</a></li><li><a href='http://www.csharp411.com/c-get-calling-method/' rel='bookmark' title='Permanent Link: C# Get Calling Method'>C# Get Calling Method</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/convert-generic-icollectiont/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>KeyedCollection: Dictionary for Values with Embedded Keys</title>
		<link>http://www.csharp411.com/keyedcollection-dictionary-for-values-with-embedded-keys/</link>
		<comments>http://www.csharp411.com/keyedcollection-dictionary-for-values-with-embedded-keys/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 16:24:19 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Dictionary]]></category>
		<category><![CDATA[GetKeyForItem]]></category>
		<category><![CDATA[IDictionary]]></category>
		<category><![CDATA[IList]]></category>
		<category><![CDATA[KeyedCollection]]></category>

		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/keyedcollection-dictionary-for-values-with-embedded-keys/</guid>
		<description><![CDATA[If you need a collection of objects accessed by a key, and the key is one of the object's properties, then you should use the KeyedCollection class instead of Dictionary.  For example, you would use a KeyedCollection to store Employee objects accessed by the employee's ID property.

The KeyedCollection class is a hybrid between an [...]


Related posts:<ol><li><a href='http://www.csharp411.com/display-an-rtf-file-thats-a-c-embedded-resource/' rel='bookmark' title='Permanent Link: Display an RTF File that's a C# Embedded Resource'>Display an RTF File that's a C# Embedded Resource</a></li><li><a href='http://www.csharp411.com/embedded-image-resources/' rel='bookmark' title='Permanent Link: Embedded Image Resources'>Embedded Image Resources</a></li><li><a href='http://www.csharp411.com/how-to-cache-an-object/' rel='bookmark' title='Permanent Link: How to Cache an Object'>How to Cache an Object</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/keyedcollection-dictionary-for-values-with-embedded-keys/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Convert Between Generic IEnumerable&lt;T&gt;</title>
		<link>http://www.csharp411.com/convert-between-generic-ienumerablet/</link>
		<comments>http://www.csharp411.com/convert-between-generic-ienumerablet/#comments</comments>
		<pubDate>Thu, 20 Sep 2007 21:43:49 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[C#-Generics]]></category>
		<category><![CDATA[Generics-Variance]]></category>
		<category><![CDATA[IEnumerable]]></category>
		<category><![CDATA[IEnumerator]]></category>

		<guid isPermaLink="false">http://www.mini-tools.com/at2/csharp/wordpress/convert-between-generic-ienumerablet/</guid>
		<description><![CDATA[Generics in .NET 2.0 provides the ability to create strongly-typed collections in C#.  Unfortunately, C# currently does not support generics variance, which would allow inheritance of generic types.
For example, consider a list of strings and a list of objects:

List&#60;string&#62; strings = new List&#60;string&#62;();
strings.Add( "hello" );
strings.Add( "goodbye" );
List&#60;object&#62; objects = new List&#60;object&#62;();
objects.AddRange( strings );

The final [...]


Related posts:<ol><li><a href='http://www.csharp411.com/convert-generic-icollectiont/' rel='bookmark' title='Permanent Link: Convert Generic ICollection&#60;T&#62;'>Convert Generic ICollection&#60;T&#62;</a></li><li><a href='http://www.csharp411.com/c-empty-enumerator/' rel='bookmark' title='Permanent Link: C# Empty Enumerator'>C# Empty Enumerator</a></li><li><a href='http://www.csharp411.com/multiple-generic-ienumerablet/' rel='bookmark' title='Permanent Link: Multiple Generic IEnumerable&lt;T&gt;'>Multiple Generic IEnumerable&lt;T&gt;</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/convert-between-generic-ienumerablet/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
