Scope of Using Statement?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Jan (Jan_at_discussions.microsoft.com)
Date: 12/02/04


Date: Thu, 2 Dec 2004 07:31:01 -0800

Hi- I'm new to .Net, a Delphi developer learning C#. What is the scope of
the using statement, or maybe a better question is how do I use it? From the
help, it looks like the scope is within a namespace.

What I have is a class library with several files. One file is a base
class, and then the other 3 files each contain a class that is derived from
the base class. Each class is in its own file, and all classes belong to the
same namespace. I've added references to the base class file:
using BTSComponentsLib;
using System.EnterpriseServices;
using System.Runtime.InteropServices;
using AspenCOM; //In-house unmanaged dll

Since all my classes belong to the same namespace, I am thinking I won't
need to add the using statements to all the files, just the base class file.
Is this reasoning accurate?

thanks,
Jan



Relevant Pages

  • Re: Scope of Using Statement?
    ... it looks like the scope is within a namespace. ... Each class is in its own file, and all classes belong to ... I've added references to the base class file: ...
    (microsoft.public.dotnet.framework)
  • RE: Scope of Using Statement?
    ... it looks like the scope is within a namespace. ... Each class is in its own file, and all classes belong to the ... I've added references to the base class file: ...
    (microsoft.public.dotnet.framework)
  • Re: Scope and program structure problems
    ... then I'd be declaring the variables/objects explicitly ... I personnally find the assignment, import, class and def statements (all having a binding behaviour) to be rather explicit. ... their scope according to how/where they were declared. ... Names bound within a class statement lives in the class's namespace ...
    (comp.lang.python)
  • Re: qualified name and unqualified name
    ... Unqualified name means no namespace qualifier ahead of a name? ... Others are unqualified (of their scope). ... understanding of "point of instantiation". ...
    (microsoft.public.vc.language)
  • Re: Need help with Python scoping rules
    ... When a class definition is entered, a new namespace is created, ... "fact" in the class scope, and the assignment statement looks up ... Its just, during class creation, the local scope. ... When you enter a class definition, a new namespace is created, and that is used as the local scope during the class's definition. ...
    (comp.lang.python)