Prev | Current Page 373 | Next

Jon Skeet

"C# in Depth: What you need to master C# 2 and 3"

Configuration??? as the compiler
resolves Configuration to that type before moving out to the namespace root. The
second line indicates that the type has to be in the global namespace, and so simply
prints ???Configuration.??? I included the third line to demonstrate that using the global
alias you can still refer to types within namespaces, but you have to specify the fully
qualified name.
At this point we can get to any uniquely named type, using the global namespace
alias if necessary??”and indeed if you ever write a code generator where the code
doesn??™t need to be readable, you may wish to use this feature liberally to make sure
that you always refer to the correct type whatever other types are actually present by
the time the code is compiled. What do we do if the type??™s name isn??™t unique even
when we include its namespace? The plot thickens??¦
7.4.3 Extern aliases
At the start of this section, I referred to human names as examples of namespaces and
contexts. I specifically said that you??™re unlikely to know more than one person called
Jon Skeet. However, I know that there is more than one person with my name, and it??™s
not beyond the realm of possibility to suppose that you might know two or more of us.
In this case, in order to specify which one you mean you have to provide some more
information beyond just the full name??”the reason you know the particular person,
or the country he lives in, or something similarly distinctive.


Pages:
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385