In C#, what's the difference between A::B
and A.B
? The only difference I've noticed is that only ::
can be used with global
, but other than that, what's the difference? Why do they both exist?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
the :: operator only works with aliases global is a special system provided alias.
so ... this works:
but not this:
This lets you escape from the hell of sub namespaces that can come about when you are integrating with a library where they have:
And you in you code have
global:: lets you find the real System.
MSDN info here
with :: you can do things like...
and there are times when . is ambiguous so :: is needed. here's the example from the C# language spec
http://download.microsoft.com/download/0/B/D/0BDA894F-2CCD-4C2C-B5A7-4EB1171962E5/CSharp%20Language%20Specification.htm