Tuesday, January 8, 2008

HybridDictionary Class

Implements IDictionary by using a ListDictionary while the collection is small, and then switching to a Hashtable when the collection gets large.


This class is recommended for cases where the number of elements in a dictionary is unknown. It takes advantage of the improved performance of a ListDictionary with small collections, and offers the flexibility of switching to a Hashtable which handles larger collections better than ListDictionary.

Thread Safety

Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Reference: http://msdn2.microsoft.com/en-us/library/system.collections.specialized.hybriddictionary.aspx

TypeForwardedTo Attribute Forward a Type to a Different Assembly

In .NET, one often refers to other assemblies that contain specific modules that you can use in your application. Say, you reference a DLL that contains some classes that you will use in your application. Suppose the application is deployed. Now, suppose you want to move one class of the DLL to another assembly. What can you do in this situation with old coding methodoligies? The old methodologies say,

  • Remove the class from the existing DLL.
  • Create another DLL (assembly) using that class.
  • Recompile both the DLLs.
  • From your application, add a reference to the new DLL.
  • Recompile the application.
  • Re-deploy the whole thing.
TypeForwardedTo  Reduces the Above Stuffs 

Open the AssemblyInfo.cs file and add the following line right after the assembly directives.

[assembly: TypeForwardedTo(typeof(MyNameSpace.MyClass))]

Reference: http://www.codeguru.com/csharp/csharp/cs_misc/dllsandexecutables/article.php/c14559__1/