Jon Shemitz <jo*@midnightbeach.com> wrote:
I'm playing with 2.0's extern alias declarations and the :: operator.
If I have an
extern alias My;
and the My namespace contains a TypeName, I can refer to My::TypeName
... or to My.TypeName.
I don't quite get this latter usage: I can *not* refer to
global::My.TypeName nor can I refer to global.System.String.
Is My.TypeName an inconsistency, or did I just miss the msdn page that
explains it?
I'm not seeing the problem you are in a test program with other names.
Here's my code:
Lib.cs:
using System;
namespace Foo.Bar
{
public class Baz
{
public static void SayHi()
{
Console.WriteLine ("Hello alias");
}
}
}
Test.cs:
extern alias Lib;
using System;
namespace Foo.Bar
{
public class Baz
{
public static void SayHi()
{
Console.WriteLine ("Hello");
}
}
}
class Test
{
static void Main()
{
// Warning (unused variable), but don't worry about it
global::System.String foo = "hello";
Foo.Bar.Baz.SayHi();
global::Foo.Bar.Baz.SayHi();
Lib::Foo.Bar.Baz.SayHi();
}
}
Compile:
csc /target:library Lib.cs
csc Test.cs /r:Lib=lib.dll
Output:
Hello
Hello
Hello alias
It still works if I change "Foo" to "My" everywhere.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too