Google


   


You are here: CodeIdol.com > C# > C# Cookbook, 2nd Edition > Generics

SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

C# Cookbook, 2nd Edition



Problem: You want to use generic types in a new project or convert nongeneric types in an existing project to their generic equivalent. However, you do not really know why you would want to do this, and you do not know which nongeneric types should ...



Problem: You need to understand how the .NET types work for generics and what differences there are from regular .NET types. Solution: A couple of quick experiments can show the differences between regular .NET types and generic .NET types. Wh...



Problem: You need to get the Type object for a generic type instance at runtime. Solution: Provide the type parameters when using the typeof operator; or instantiate the generic type using the type parameters, then use the GetType( ) method. ...



Problem: You want to enhance the performance of your application as well as make the code easier to work with by replacing all ArrayList objects with the generic version. This is imperative when you find that structures or other value types are bein...



Problem: You want to enhance the performance of your application as well as make the code easier to work with by replacing all Stack and Queue objects with their generic versions. This is imperative when you find that structures or other value types...



Problem: You need a linked data structure that allows you to easily add and remove elements. Solution: Use the generic LinkedList<T> class. The following method creates a LinkedList<T> class, adds nodes to this linked list object, ...



Problem: You have a variable that is a numeric type, which will hold a numeric value obtained from a database. The database may return this value as a null. You need a simple clean way to store this numeric value, even if it is returned as a null. ...



Problem: You want to be able to reverse the contents of a sorted list of items while also maintaining the ability to access them in both array and list styles like SortedList and the generic SortedList<T> classes provide. Neither SortedList no...



Problem: You have a collection of information that you want to expose from your class, but you don't want any users modifying the collection. Solution: Use the ReadOnlyCollection<T> wrapper to easily support collection classes that canno...



Problem: You want to enhance the performance of your application as well as make the code easier to work with by replacing all Hashtable objects with the generic version. This is imperative when you find that structures or other value types are bein...



Problem: You need to enumerate the elements within a type that implements System. Collections.Generic.IDictionary, such as System.Collections.Generic.Dictionary or System.Collections.Generic.SortedList. Solution: The simplest way is to use the...



Problem: Your generic type needs to be created with a type argument that must support the members of a particular interface such as the IDisposable interface. Solution: Use constraints to force the type arguments of a generic type to be of a t...



Problem: You have a generic class that contains a variable of the same type as the type parameter defined by the class itself. Upon construction of your generic object, you want that variable to be initialized to its default value. Solution: S...


SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

You are here: CodeIdol.com > C# > C# Cookbook, 2nd Edition > Generics


ADBRITE ads links
   
Related tags







Popular Categories
Unix books and guides

AJAX popular information
C# language guides
Windows books and cookbooks

.......








Business Key Top Sites

be number one
rate your site




    С 2009 года мы стали переводить структура сайта на различные языки. Сайт теперь будет содержать книги не только на английском языке, но также и на других европейских языках, в том числе и на Русском языке.

    Русский Polski Francais Deutsch
    support sitemap terms

© CodeIdol Labs, 2007 - 2009