By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,521 Members | 1,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,521 IT Pros & Developers. It's quick & easy.

A class and namespace has same name, but still must fully qualify the class???

P: n/a
Hi,
I have a single class XXX residing in a namspace with the same name:
XXX.

I can access my class in my code just fine with:

XXX.XXX.MySub() '(Note: shared sub!)

But I don't want to clutter the code with the namespace every time I
access my class.
o, as per usual, I add in the 'Imports XXX' into my code. So now I can
just access my class like:

XXX.MySub()

right? Wrong. The IDE STILL forces me to fully qualify the class with
the namespace !!??!!

I *think* its getting confused because the class name is the same name
as the namespace.
How can I avoid this?

Thanks,
Jack.

Jul 10 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Jack,

If you use as your class by instance the name streamwriter, than it can
become ambigious and you have to qualify both full.

Cor

"Jack" <br*********@hotmail.comschreef in bericht
news:11**********************@i13g2000prf.googlegr oups.com...
Hi,
I have a single class XXX residing in a namspace with the same name:
XXX.

I can access my class in my code just fine with:

XXX.XXX.MySub() '(Note: shared sub!)

But I don't want to clutter the code with the namespace every time I
access my class.
o, as per usual, I add in the 'Imports XXX' into my code. So now I can
just access my class like:

XXX.MySub()

right? Wrong. The IDE STILL forces me to fully qualify the class with
the namespace !!??!!

I *think* its getting confused because the class name is the same name
as the namespace.
How can I avoid this?

Thanks,
Jack.

Jul 10 '07 #2

P: n/a
Jack wrote:
Hi,
I have a single class XXX residing in a namspace with the same name:
XXX.

I can access my class in my code just fine with:

XXX.XXX.MySub() '(Note: shared sub!)

But I don't want to clutter the code with the namespace every time I
access my class.
o, as per usual, I add in the 'Imports XXX' into my code. So now I can
just access my class like:

XXX.MySub()

right? Wrong. The IDE STILL forces me to fully qualify the class with
the namespace !!??!!

I *think* its getting confused because the class name is the same name
as the namespace.
How can I avoid this?
By not having a class with the same name as it's namespace.

--
Göran Andersson
_____
http://www.guffa.com
Jul 10 '07 #3

P: n/a
On Jul 10, 11:35 am, Jack <bradnerd...@hotmail.comwrote:
Hi,
I have a single class XXX residing in a namspace with the same name:
XXX.

I can access my class in my code just fine with:

XXX.XXX.MySub() '(Note: shared sub!)

But I don't want to clutter the code with the namespace every time I
access my class.
o, as per usual, I add in the 'Imports XXX' into my code. So now I can
just access my class like:

XXX.MySub()

right? Wrong. The IDE STILL forces me to fully qualify the class with
the namespace !!??!!

I *think* its getting confused because the class name is the same name
as the namespace.
How can I avoid this?

Thanks,
Jack.
Thanks.

Jul 10 '07 #4

P: n/a
Jack,
As Göran suggests avoid naming a class & namespace the same.

If there is no way around this, for example the class is coming from one
assembly & the namespace from another. You could use an import alias to
locally (to the file) "rename" the namespace or class

Imports ba = XXX.XXX

ba.MySub()

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Jack" <br*********@hotmail.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
Hi,
I have a single class XXX residing in a namspace with the same name:
XXX.

I can access my class in my code just fine with:

XXX.XXX.MySub() '(Note: shared sub!)

But I don't want to clutter the code with the namespace every time I
access my class.
o, as per usual, I add in the 'Imports XXX' into my code. So now I can
just access my class like:

XXX.MySub()

right? Wrong. The IDE STILL forces me to fully qualify the class with
the namespace !!??!!

I *think* its getting confused because the class name is the same name
as the namespace.
How can I avoid this?

Thanks,
Jack.
Jul 11 '07 #5

P: n/a
On Jul 11, 8:06 am, "Jay B. Harlow [MVP - Outlook]"
<Jay_Harlow_...@tsbradley.netwrote:
Jack,
As Göran suggests avoid naming a class & namespace the same.

If there is no way around this, for example the class is coming from one
assembly & the namespace from another. You could use an import alias to
locally (to the file) "rename" the namespace or class

Imports ba = XXX.XXX

ba.MySub()

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -http://www.tsbradley.net

"Jack" <bradnerd...@hotmail.comwrote in message

news:11**********************@i13g2000prf.googlegr oups.com...
Hi,
I have a single class XXX residing in a namspace with the same name:
XXX.
I can access my class in my code just fine with:
XXX.XXX.MySub() '(Note: shared sub!)
But I don't want to clutter the code with the namespace every time I
access my class.
o, as per usual, I add in the 'Imports XXX' into my code. So now I can
just access my class like:
XXX.MySub()
right? Wrong. The IDE STILL forces me to fully qualify the class with
the namespace !!??!!
I *think* its getting confused because the class name is the same name
as the namespace.
How can I avoid this?
Thanks,
Jack.- Hide quoted text -

- Show quoted text -
I also noticed this problem occurrs with the framework itself with the
StringBuilder class. One must fully qualify it with:
Dim testString As New System.Text.StringBuilder(30)
because the IDE seems to think 'StringBuilder' is some namespace and
not a class in the following statement:
Dim testString As New StringBuilder(30)

I consider this an oversight with the Visual Studio product. I'm not
sure what to blame though: is it the IDE, intellisense, or the dynamic
IDE compiler?

Jack.

Jul 11 '07 #6

P: n/a
Jack wrote:
On Jul 11, 8:06 am, "Jay B. Harlow [MVP - Outlook]"
<Jay_Harlow_...@tsbradley.netwrote:
>Jack,
As Göran suggests avoid naming a class & namespace the same.

If there is no way around this, for example the class is coming from one
assembly & the namespace from another. You could use an import alias to
locally (to the file) "rename" the namespace or class

Imports ba = XXX.XXX

ba.MySub()

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -http://www.tsbradley.net

"Jack" <bradnerd...@hotmail.comwrote in message

news:11**********************@i13g2000prf.googleg roups.com...
>>Hi,
I have a single class XXX residing in a namspace with the same name:
XXX.
I can access my class in my code just fine with:
XXX.XXX.MySub() '(Note: shared sub!)
But I don't want to clutter the code with the namespace every time I
access my class.
o, as per usual, I add in the 'Imports XXX' into my code. So now I can
just access my class like:
XXX.MySub()
right? Wrong. The IDE STILL forces me to fully qualify the class with
the namespace !!??!!
I *think* its getting confused because the class name is the same name
as the namespace.
How can I avoid this?
Thanks,
Jack.- Hide quoted text -
- Show quoted text -

I also noticed this problem occurrs with the framework itself with the
StringBuilder class. One must fully qualify it with:
Dim testString As New System.Text.StringBuilder(30)
because the IDE seems to think 'StringBuilder' is some namespace and
not a class in the following statement:
Dim testString As New StringBuilder(30)

I consider this an oversight with the Visual Studio product. I'm not
sure what to blame though: is it the IDE, intellisense, or the dynamic
IDE compiler?

Jack.
I have never experienced that, but then I use C#, not VB.

There is no StringBuilder namespace, so I have no idea why the IDE would
think there is. Unless you have created a StringBuilder namespace in
your project?

--
Göran Andersson
_____
http://www.guffa.com
Jul 11 '07 #7

P: n/a
On Tue, 10 Jul 2007 23:04:23 -0700, Jack <br*********@hotmail.com>
wrote:
>On Jul 11, 8:06 am, "Jay B. Harlow [MVP - Outlook]"
<Jay_Harlow_...@tsbradley.netwrote:
>Jack,
As Göran suggests avoid naming a class & namespace the same.

If there is no way around this, for example the class is coming from one
assembly & the namespace from another. You could use an import alias to
locally (to the file) "rename" the namespace or class

Imports ba = XXX.XXX

ba.MySub()

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -http://www.tsbradley.net

"Jack" <bradnerd...@hotmail.comwrote in message

news:11**********************@i13g2000prf.googleg roups.com...
Hi,
I have a single class XXX residing in a namspace with the same name:
XXX.
I can access my class in my code just fine with:
XXX.XXX.MySub() '(Note: shared sub!)
But I don't want to clutter the code with the namespace every time I
access my class.
o, as per usual, I add in the 'Imports XXX' into my code. So now I can
just access my class like:
XXX.MySub()
right? Wrong. The IDE STILL forces me to fully qualify the class with
the namespace !!??!!
I *think* its getting confused because the class name is the same name
as the namespace.
How can I avoid this?
Thanks,
Jack.- Hide quoted text -

- Show quoted text -

I also noticed this problem occurrs with the framework itself with the
StringBuilder class. One must fully qualify it with:
Dim testString As New System.Text.StringBuilder(30)
because the IDE seems to think 'StringBuilder' is some namespace and
not a class in the following statement:
Dim testString As New StringBuilder(30)

I consider this an oversight with the Visual Studio product. I'm not
sure what to blame though: is it the IDE, intellisense, or the dynamic
IDE compiler?
I never qualify StringBuilder and haved never had any problems with it
(VB 2005).
Jul 11 '07 #8

P: n/a
Jack
I also noticed this problem occurrs with the framework itself with the
StringBuilder class. One must fully qualify it with:
Dim testString As New System.Text.StringBuilder(30)
because the IDE seems to think 'StringBuilder' is some namespace and
not a class in the following statement:
Dim testString As New StringBuilder(30)
You forgot an "Imports System.Text" as the top of the current file.
I consider this an oversight with the Visual Studio product. I'm not
sure what to blame though: is it the IDE, intellisense, or the dynamic
IDE compiler?
I would blame the user forgetting to import the namespace. ;-)
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Jack" <br*********@hotmail.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
On Jul 11, 8:06 am, "Jay B. Harlow [MVP - Outlook]"
<Jay_Harlow_...@tsbradley.netwrote:
Jack,
As Göran suggests avoid naming a class & namespace the same.

If there is no way around this, for example the class is coming from one
assembly & the namespace from another. You could use an import alias to
locally (to the file) "rename" the namespace or class

Imports ba = XXX.XXX

ba.MySub()

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -http://www.tsbradley.net

"Jack" <bradnerd...@hotmail.comwrote in message

news:11**********************@i13g2000prf.googlegr oups.com...
Hi,
I have a single class XXX residing in a namspace with the same name:
XXX.
I can access my class in my code just fine with:
XXX.XXX.MySub() '(Note: shared sub!)
But I don't want to clutter the code with the namespace every time I
access my class.
o, as per usual, I add in the 'Imports XXX' into my code. So now I can
just access my class like:
XXX.MySub()
right? Wrong. The IDE STILL forces me to fully qualify the class with
the namespace !!??!!
I *think* its getting confused because the class name is the same name
as the namespace.
How can I avoid this?
Thanks,
Jack.- Hide quoted text -

- Show quoted text -
I also noticed this problem occurrs with the framework itself with the
StringBuilder class. One must fully qualify it with:
Dim testString As New System.Text.StringBuilder(30)
because the IDE seems to think 'StringBuilder' is some namespace and
not a class in the following statement:
Dim testString As New StringBuilder(30)

I consider this an oversight with the Visual Studio product. I'm not
sure what to blame though: is it the IDE, intellisense, or the dynamic
IDE compiler?

Jack.

Jul 14 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.