The following doesn't compile
public static T Retrieve<T>(this NameValueCollection collection, String key) where T : Object
{
if (collection.AllKeys.Contains(key))
{
try
{
val = (T)Convert.ChangeType((object)collection[key], typeof(T));
}
catch { }
}
return val;
}
because the Constraint cannot be the object class. So is there a way to contrain T for anything that can be set to a null?