"Generic" Collections as we see them today
Currently, if we want to handle our Types in a generic manner, we always need to cast them to a System.Object, and we lose any benefit of a rich-typed development experience. For example, I'm sure most of us are familiar with the System.Collection.ArrayList class in Framework v1 and v1.1. If you have used it at all, you will notice a few things about it:
-----------------------------------------------------------------------------------
public class Col
{
T t;
public T Val
{
get
{
return t;
}
set
{
t = value;
}
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Col
cStr.Val = "some text";
this.listBox1.Items.Add(cStr.Val.ToString());
this.listBox1.Items.Add(cStr.GetType().ToString());
Col
cInt.Val = 100;
this.listBox1.Items.Add(cInt.Val.ToString());
this.listBox1.Items.Add(cInt.GetType().ToString());
}
}
-----------------------------------------------------------------------------------
Reference: http://www.15seconds.com/issue/031024.htm