C# Generics Recipes

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:Articles
C# Articles

C# Generics Recipes

© 2006 O'Reilly Media, Inc.
This article—CSharp Generics Recipes—is from C# Cookbook, 2nd edition, by Jay Hilyard, Stephen Teilhet. Copyright © 2006 O'Reilly Media, Inc. All rights reserved. Reproduced by permission. This article has been edited especially for C# Online.NET.  Read the book review! CSharpCookBookOReilly.jpg


C# Generics Recipes

4.0 Introduction

A long-awaited feature, generics, is finally here with the advent of Version 2.0 of the C# compiler. Generics is an extremely useful feature that allows you to write less, but more efficient, code. This aspect of generics is detailed more in Recipe 4.1. With generics comes quite a bit of programming power, but with that power comes the responsibility to use it correctly. If you are considering converting your ArrayList, Queue, Stack, and Hashtable objects to use their generic counterparts, consider reading Recipes 4.4, 4.5, and 4.10. As you will read, the conversion is not always simple and easy, and there are reasons why you might not want to do this conversion at all.

Other recipes in this chapter deal with other generic classes contained in the .NET Version 2.0 Framework, such as Recipe 4.6. Still others deal with the operation of any generic type, such as Recipes 4.2, 4.8, and 4.13.


Previous_Page_.gif Next_Page_.gif


Personal tools