Namespaces - Please explain this

  • Thread starter Thread starter GingerDeafMan
  • Start date Start date
G

GingerDeafMan

Hi,

This is ok:

using System.Windows.Forms;
private System.Windows.Form Form1;

(the private declaration is in a class, of course)

As is:

using System.Windows.Forms;
private Form Form1;

But the compiler does not like this:

using System.Windows;
private Forms.Form Form1;

Why is this and what are the rules?

Cheers,

Paul.
 
The heirarchical nature of namespaces is a pretence that the C# syntax likes to allow - you should think of the namespace as an opaque string (not comprised of its constituent parts). Unofortunately the C# compiler doesn't carry this pretence through fully as you have found.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Hi,

This is ok:

using System.Windows.Forms;
private System.Windows.Form Form1;

(the private declaration is in a class, of course)

As is:

using System.Windows.Forms;
private Form Form1;

But the compiler does not like this:

using System.Windows;
private Forms.Form Form1;

Why is this and what are the rules?

Cheers,

Paul.




--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.7.1 - Release Date: 19/01/2005



[microsoft.public.dotnet.languages.csharp]
 
Hi Paul,

There is no System.Windows namespace, and there is no Forms class.
You call upon the Form class (not Forms) and it is located inside the
System.Windows.Forms namespace.

You can provide shortcuts for class names with using statements and a
valid namespace but you cannot split parts of namespaces.
 
Back
Top