"using" alias in global scope

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • VRSki

    "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.B yte;

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

    Thanks,
    VR


  • Jon Skeet [C# MVP]

    #2
    Re: "using&quo t; alias in global scope

    VRSki <VRSki@newsgrou p.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 - <skeet@pobox.co m>
    http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
    World class .NET training in the UK: http://iterativetraining.co.uk

    Comment

    • Steven Cheng[MSFT]

      #3
      RE: &quot;using&quo t; 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)


      Sincerely,

      Steven Cheng

      Microsoft MSDN Online Support Lead


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



      --------------------
      >From: "VRSki" <VRSki@newsgrou p.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.B yte;
      >
      >namespace MyNamespace
      >{
      public static void Foo()
      {
      MyByte b = 0;
      }
      >}
      >
      >Thanks,
      >VR
      >
      >
      >

      Comment

      • Steven Cheng[MSFT]

        #4
        RE: &quot;using&quo t; alias in global scope

        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" <VRSki@newsgrou p.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.B yte;
        >>
        >>namespace MyNamespace
        >>{
        > public static void Foo()
        > {
        > MyByte b = 0;
        > }
        >>}
        >>
        >>Thanks,
        >>VR
        >>
        >>
        >>
        >
        >

        Comment

        Working...