O'Reilly logo

Cross-platform UI Development with Xamarin.Forms by Paul F. Johnson

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

.NET generics

With the advent of .NET 2.0, this problem was solved; Microsoft introduced generics to the mix. The generic classes are instantiated once and then you can add to them as many times as you like. The framework itself does the memory management for the list, so they can be considered as an ever-extendable array.

In which case, why are they called generics as arrays have a definite type (string, int, byte and so on)? The answer to that is the type argument. A .NET generic takes a generic type (typically referred to as T). This T can be anything—even another generic (for example, there is nothing to stop you from having List<Dictionary<T, List<U>>>, the caveat being that T and U will need to be defined somewhere).

This obviously will mean ...

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