Generic code must work for every type of data. You can specify type constraints for…
We learned that arrays allow you to store multiple values with the same datatype. The arrays inherit the System.Array abstract class which provides methods and properties for simple data such as the length of the array. Ordinary arrays in C# have fixed length and once they have been declared with an initial length, you cannot increase or decrease the length of that particular array. The .NET Framework offers a better alternative to arrays and most of those classes and interfaces are contained inside the System.Collections namespace.
For example, the ArrayList class has the same basic behavior as the normal Array but it allows you to dynamically change the length and add or remove its elements during program execution. In the following exercises, we will discover how to create a class that contains a collection of objects by implementing or inheriting certain interfaces and methods.