What are the rules for searching Type.GetType for a type name prefixed with "."?

eg. Type.GetType(".System.Collections.ArrayList", false, false) vs. Type.GetType("System.Collections.ArrayList", false, false)

I assumed that they are equivalent, but I noticed that the former takes twice as much time as the latter to solve, and after further investigation I cannot find any explicit support for the former: http://msdn.microsoft.com/en -us / library / w3f99sx1.aspx .

Are these equivalents, and if so, any idea why the first is twice as large as the last to decide?

+4
source share
2 answers

From the link provided:

Period ( . ) Indicates namespace identifiers.

I would suggest a presenter . causes a check for all namespaces, even those that are outside the current assembly.

0
source

There is no concept of a global namespace, because the namespaces that you have open do not matter in this context.

Think about it, as always looking for the root (global). Type.GetType is not β€œin” the namespace and does not have public namespaces. You must determine the type you are looking for, including its namespace.

0
source

Source: https://habr.com/ru/post/1384585/


All Articles