Chapter 3. Parameterized typing with generics

 

This chapter covers

  • Type inference for generic methods
  • Type constraints
  • Reflection and generics
  • CLR behavior
  • Limitations of generics
  • Comparisons with other languages

True story:[1] The other day my wife and I went out to do our weekly grocery shopping. Just before we left, she asked me if I had the list. I confirmed that I did have the list, and off we went. It was only when we got to the grocery store that our mistake became obvious. My wife had been asking about the shopping list, whereas I’d brought the list of neat features in C# 2. When we asked an assistant whether we could buy any anonymous methods, we received a strange look.

1 By which I mean “convenient for the purposes of introducing the chapter”—not necessarily accurate.

If only we could’ve expressed ourselves more clearly! If only she’d had some way of saying that she wanted me to bring the list of items we wanted to buy! If only we’d had generics...

3.1. Why generics are necessary

 
 
 

3.2. Simple generics for everyday use

 
 

3.3. Beyond the basics

 

3.4. Advanced generics

 
 

3.5. Limitations of generics in C# and other languages

 

3.6. Summary

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage