"using" alias in global scope

V

VRSki

Hello,

Is there any way to use "using" for aliasing in the global scope?

The example below works fine in the context of a given file, but in the
different file MyByte alias is unknown. Is there any way to extend its
visibility to multiple files without redefining it?

using MyByte=System.Byte;

namespace MyNamespace
{
public static void Foo()
{
MyByte b = 0;
}
}

Thanks,
VR
 
J

Jon Skeet [C# MVP]

VRSki said:
Is there any way to use "using" for aliasing in the global scope?

The example below works fine in the context of a given file, but in the
different file MyByte alias is unknown. Is there any way to extend its
visibility to multiple files without redefining it?

No - a using directive only ever applies to the file it occurs in.
 
S

Steven Cheng[MSFT]

Hi VR,

As for the using directive, as Jon has mentioned, it is limited to the file
where it is declared. The MSDN reference on using directive also ponit out
the scope of using:

#using Directive (C# Reference)
http://msdn2.microsoft.com/en-us/library/sf0df423(VS.80).aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
 
S

Steven Cheng[MSFT]

Hi VR,

Have you any other questions on this? If so, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top