473,378 Members | 1,527 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,378 software developers and data experts.

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

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
8 1875
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Neil Zanella | last post by:
Hello, I would like to know whether it is possible to define static class methods and data members in Python (similar to the way it can be done in C++ or Java). These do not seem to be mentioned...
2
by: Jan | last post by:
Here's the code with the problem: class Startup { public static string Sym; public static string PrevDate; public static int Highest = new int; // ______________
7
by: +The_Taco+ | last post by:
Ok i'm kinda new to ASP.NET. I got like 4 aspx pages right now, all with there aspx.vb codebehind. Each of them need to connect on the same database, so what I want to do is to create a module or a...
3
by: MattB | last post by:
Server.MapPath works fine for me in a CodeBehind file, but when I try and move that code to a vb class it doesn't. What do I need to change to make Server.MapPath work from my vb class? Thanks! ...
10
by: Davíđ Ţórisson | last post by:
Please can someone tell me how on earth to create an instance of my top level (base) Page class so that I can access it's objects from an user control?? Someone told me public myParent =...
23
by: patang | last post by:
When I create my own class, to use the functions of that class I have to create an object of that class and then I can access the functions of that class, for example: dim obj1 as myclass...
3
by: tuanhoanganh | last post by:
My program has class's name same namespace 's name. Ex namespace clsvoucher public class clsvoucher .......... end class end namespace Can I use Dim a as clsvoucher or I must use Dim a as...
3
by: nadeem_far | last post by:
Hello All, I have a couple of questions and I am not able to find them any where on internet. 1. We are using a third party class library which exposes a class with the name of "class". ...
7
by: Juha Nieminen | last post by:
This is possible: namespace X { class A; } class X::A { <implementation}; However, what about nameless namespaces? Does this do what I want? namespace { class A; }
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.