O'Reilly logo

Effective C#: 50 Specific Ways to Improve Your C#, Third Edition by Bill Wagner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3. Working with Generics

Some articles and papers might lead you to believe that generics are useful only in the context of collections. That’s not true. There are many other ways to use generics. You can use them to create interfaces, event handlers, common algorithms, and more.

Many other discussions compare C# generics to C++ templates, usually to advocate one as being better than the other. Comparing C# generics to C++ templates is useful to help you understand the syntax, but that’s where the comparison should end. Certain idioms are more natural to C++ templates, and others are more natural to C# generics. But, as you’ll see in Item 19 a bit later in this chapter, trying to decide which is “better” will only hurt your understanding of both ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required