+1  A: 

Try this:

string s = (string)Activator.CreateInstance(t);

Activator.CreateInstance returns an instance boxed in an object so it must be cast to the correct type before you can use it.

In your example t is a Type object variable and not a type reference. You must either specify the type directly as in my example or you can use generics.

Rune Grimstad
+4  A: 

Yes. You have to convert to string, not to t. You may want a generic method, alternatively:

public T GetInstance<T>()
{
    Type t = typeof(T);
    T s = (T)Activator.CreateIstance(t);
    return s;
}

As things stand you are attempting to cast an object that is actually an instance of System.String to type System.Type...

David M
You could just add a `where T : new()` contstraint on the method and the body would then be a single line: `return new T();`
LukeH
Very true, and would be safer as types not implementing a paramaterless constructor could be picked up at compile time.
David M
If I recall correctly there is a generic overload as well, so you should be able to do Activator.CreateInstance<T>();
Jaco Pretorius