473,382 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Namespaces - Please explain this

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.

Nov 16 '05 #1
2 1010
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]
Nov 16 '05 #2
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.

On Fri, 21 Jan 2005 09:45:11 -0000, GingerDeafMan
<gi*****************@yahoo.co.uk> wrote:
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.


--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rubén Campos | last post by:
Organizing classes, types, structures, enums and whatever other entities into nested namespaces requires to include into every header and implementation file the complete path of namespaces. Let me...
3
by: Jim Heavey | last post by:
Trying to get the hang of Namespaces. I have primarly developed in VB and am transitioning to C# and the .Net Environment. I have worked a bit with Java as well in school about a year or so ago....
9
by: Patty O'Dors | last post by:
Hi Can somebody please tell me what namespaces are actually for? I notice that when I start a new project in C#, it puts everything in a namespace of the same name as the project. I found them...
17
by: clintonG | last post by:
Using 2.0 with Master Pages and a GlobalBaseClass for the content pages. I understand the easy part -- the hierarchical structure of a namespace naming convention -- but the 2.0 IDE does not...
11
by: Random | last post by:
I'm confused about the proper use and usefulness of namespaces. I beleive I understand the purpose is so the developer can put classes within namespaces to essentially organize your code. And I...
36
by: Wilfredo Sánchez Vega | last post by:
I'm having some issues around namespace handling with XML: >>> document = xml.dom.minidom.Document() >>> element = document.createElementNS("DAV:", "href") >>> document.appendChild(element)...
4
by: bob | last post by:
how do you import multiple namespaces from the same header?
6
by: =?Utf-8?B?TUNN?= | last post by:
What is the difference between importing a namespace at the: 1. Project level 2. web.config level 3. Page level What are the requirements/benefits of each? If I import a namespace such as...
3
by: moltendorf | last post by:
I've been looking over some of the newer features of PHP 5.3 and notice that they have updated the namespace documentation. I have been programming with the dev builds with this new system, and have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.