How can you store a Type for future use?

I'd like to do something like this...

System.Type colliderType = ColliderTypeFromName();
if (colliderType != null) gameObject.AddComponent<colliderType>();

System.Type ColliderTypeFromName () {
    if (name.Contains("box"))   return typeof(BoxCollider);
    if (name.Contains("sphere"))    return typeof(SphereCollider);
    if (name.Contains("capsule"))   return typeof(CapsuleCollider);
    return null;
}

...but AddComponentcolliderType() doesn't work. What would work instead?

Generics don't take a System.Type type, per se. As best as I can tell from the MSDN docs, it's actually a "type parameter" or "template." There's a fairly in-depth discussion on this Stack Overflow question on the topic. To get around that, though, you can change your `AddComponent` call to the non-generic type (which does take a System.Type argument) and it seems to work OK:

System.Type colliderType = ColliderTypeFromName();
if (colliderType != null) gameObject.AddComponent (colliderType);

this would work:

System.Type colliderType = ColliderTypeFromName();
gameObject.AddComponent(colliderType);

that said, this code does smell a bit, and I suspect that if you provide a bit more context of the problem you're trying to solve, a more elegant solution would be available.