Qualified type names and GetType(String)

K

KK

Two quick questions:

1.) Given only a string containing fully qualified type name (e.g.
"System.Drawing.Rectangle"), is there a consistent way to get the Type
object that the string corresponds to that will work with most types?

2.) If no to question 1, then given the string containing the fully
qualified type name, is there a way to get the fully qualified assembly
containing that type?

Thanks again for your help. =)
 
M

Mattias Sjögren

1.) Given only a string containing fully qualified type name (e.g.
"System.Drawing.Rectangle"), is there a consistent way to get the Type
object that the string corresponds to that will work with most types?

2.) If no to question 1, then given the string containing the fully
qualified type name, is there a way to get the fully qualified assembly
containing that type?


In general the answer is no to both questions, since multiple
assemblies can contain types with the same type name in the same
namespace. You either need an assembly-qualified type name or somehow
restrict the set of assemblies to look in.



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top