Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best resource for learning .NET generics? [closed]

Tags:

c#

.net

generics

I've never used any of the .NET generics in my work, but I understand that they are fairly popular. Does anyone have any good links or book suggestions for learning them? As a bonus; I only vaguely understand what .NET generic collections are and what they do...does anyone have any practical examples of how they might be used to greater advantage than the normal collections in .NET?

like image 420
BKimmel Avatar asked Sep 17 '08 16:09

BKimmel


People also ask

Which version of .NET the generic collection is introduced?

First introduced in . NET Framework 2.0, generics are essentially a "code template" that allows developers to define type-safe data structures without committing to an actual data type.

Are generics faster?

The generic function won't be faster than any of the corresponding type-specific functions.

What is an advantage of using generics in net?

Generics shift the burden of type safety from you to the compiler. There is no need to write code to test for the correct data type because it is enforced at compile time. The need for type casting and the possibility of run-time errors are reduced. Better performance.

What is generic classes in C sharp?

Generic is a class which allows the user to define classes and methods with the placeholder. Generics were added to version 2.0 of the C# language. The basic idea behind using Generic is to allow type (Integer, String, … etc and user-defined types) to be a parameter to methods, classes, and interfaces.


1 Answers

The obvious choice..

MSDN C# Generics

like image 55
Ian P Avatar answered Sep 17 '22 18:09

Ian P