Scope of Using Statement?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Hi Jan,

You have to declare the "using" statements in every source file, regardless
of namespace similarity or inheritance.

-- Jake
 
No. Those are per file. They do nothing except allow you to not have to
type in the fully qualified names of all the classes you will use - they are
just compiler hints, and have nothing to do with inheritance, etc.
 
Back
Top