469,917 Members | 1,866 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

"using" alias in global scope

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
Dec 5 '07 #1
3 11392
VRSki <VR***@newsgroup.nospamwrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Dec 5 '07 #2
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/lib...23(VS.80).aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "VRSki" <VR***@newsgroup.nospam>
Subject: "using" alias in global scope
Date: Wed, 5 Dec 2007 14:17:50 -0800

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
Dec 6 '07 #3
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.
--------------------
>Organization: Microsoft
Date: Thu, 06 Dec 2007 04:14:14 GMT
Subject: RE: "using" alias in global scope

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/lib...23(VS.80).aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>>From: "VRSki" <VR***@newsgroup.nospam>
Subject: "using" alias in global scope
Date: Wed, 5 Dec 2007 14:17:50 -0800

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

Dec 10 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by beliavsky | last post: by
4 posts views Thread by Teddy | last post: by
9 posts views Thread by bubbakittee | last post: by
1 post views Thread by Jason Huang | last post: by
15 posts views Thread by arnuld | last post: by
65 posts views Thread by Spiros Bousbouras | last post: by
reply views Thread by Luis Zarrabeitia | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.