Dynamic namespaced class with alias

后端 未结 1 1400
野性不改
野性不改 2021-01-21 07:35

SO,

I have an issue with dynamic object creation using namespaces. Here\'s namespace code:

namespace Foo
{
   class Bar
   {
   }
}

No

相关标签:
1条回答
  • 2021-01-21 08:25

    Only the parser uses your namespace aliases to canonicalize the class references inside each of your files.

    In other words, it doesn't introduce some kind of global alias that other code can use. Once your script has been parsed, the alias is no longer used.

    This behaviour is also described in the manual:

    Importing is performed at compile-time, and so does not affect dynamic class, function or constant names.

    0 讨论(0)
提交回复
热议问题