Type.GetType("TheClass");
Returns null
if the namespace
is not present like:
Type.GetType("SomeNamespace.TheClass"); // returns a Type object
Is there any way to avoid giving the namespace
name?
Type.GetType("TheClass");
Returns null
if the namespace
is not present like:
Type.GetType("SomeNamespace.TheClass"); // returns a Type object
Is there any way to avoid giving the namespace
name?
This should work
Use
Where
instead ofFirstOrDefault
for an array or resultsThat's the parameter the method expect to get, so no. You can not.
MSDN
How do you expect to distinguish between two classes with the same name but different Namespace?
I've used a helper method that searches all loaded Assemblys for a Type matching the specified name. Even though in my code only one Type result was expected it supports multiple. I verify that only one result is returned every time I used it and suggest you do the same.