Please see my other C# articles.
Ensuring type-safety in objects.
Whenever performing domain modeling, it’s critical to ensure code matches the real-world environment as much as possible.
The chief method for doing so to utilize classes by which objects may be instantiated.
However, having a collection of objects that are either the incorrect type or contain incorrect data types nullifies the purpose for having such collections.
Therefore, C# was updated to provide a new type, Generics.
They ensure objects stored in a collection are the correct type and also natively only support intended data types.
In the example below taken from the Nested Repeaters example, you’ll see I make use of generics to store a collection of “order” objects.