Generic Types
Learn about classes that accept type parameters.
We'll cover the following...
We'll cover the following...
Introduction
Consider the following Holder class:
public class Holder
{
public string[] Items { get; private set; }
public Holder(int holderSize)
{
Items = new string[holderSize];
}
public override string ToString()
{
string result = "Items inside: ";
foreach (var item in Items)
{
result = result + item + " ";
}
return result;
}
}
It has the Items property, which is string type. The Holder class holds string items. What if we need a similar class that holds integers? The functionality is the same, but the type is different. ...