473,986 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1912
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*********@ho tmail.comschree f in bericht
news:11******** **************@ i13g2000prf.goo glegroups.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...@ho tmail.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*********@ho tmail.comwrote in message
news:11******** **************@ i13g2000prf.goo glegroups.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.netw rote:
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.n et

"Jack" <bradnerd...@ho tmail.comwrote in message

news:11******** **************@ i13g2000prf.goo glegroups.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.Str ingBuilder(30)
because the IDE seems to think 'StringBuilder' is some namespace and
not a class in the following statement:
Dim testString As New StringBuilder(3 0)

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.netw rote:
>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.n et

"Jack" <bradnerd...@ho tmail.comwrote in message

news:11******* *************** @i13g2000prf.go oglegroups.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.Str ingBuilder(30)
because the IDE seems to think 'StringBuilder' is some namespace and
not a class in the following statement:
Dim testString As New StringBuilder(3 0)

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*********@ho tmail.com>
wrote:
>On Jul 11, 8:06 am, "Jay B. Harlow [MVP - Outlook]"
<Jay_Harlow_.. .@tsbradley.net wrote:
>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.n et

"Jack" <bradnerd...@ho tmail.comwrote in message

news:11******* *************** @i13g2000prf.go oglegroups.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
StringBuilde r class. One must fully qualify it with:
Dim testString As New System.Text.Str ingBuilder(30)
because the IDE seems to think 'StringBuilder' is some namespace and
not a class in the following statement:
Dim testString As New StringBuilder(3 0)

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.Str ingBuilder(30)
because the IDE seems to think 'StringBuilder' is some namespace and
not a class in the following statement:
Dim testString As New StringBuilder(3 0)
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*********@ho tmail.comwrote in message
news:11******** **************@ i13g2000prf.goo glegroups.com.. .
On Jul 11, 8:06 am, "Jay B. Harlow [MVP - Outlook]"
<Jay_Harlow_... @tsbradley.netw rote:
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.n et

"Jack" <bradnerd...@ho tmail.comwrote in message

news:11******** **************@ i13g2000prf.goo glegroups.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.Str ingBuilder(30)
because the IDE seems to think 'StringBuilder' is some namespace and
not a class in the following statement:
Dim testString As New StringBuilder(3 0)

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
8050
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 in "Learning Python" by Mark Lutz and David Ascher. It seems like they are a relatively new feature... It seems to me that any truly OO programming language should support these so I'm sure that Python is no exception, but how can these be...
2
11293
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
1310
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 class, wich contain a function to connect to the database. How to I include a class or a module to my codebehind pages? May someone give me a hint? thx a lot guys.
3
6686
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! Matt
10
6064
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 = (default_aspx) this.Page; where default_aspx is the class name of the base Page...
23
1493
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 obj1 = new myclass obj1.myfunction("parameter")
3
1325
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 clsvourcher.clsvourcher ? Thank. Sorry for my english
3
2291
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". Now how can i create an object of this "class" class as class is a reserve word in C#.
7
2091
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
10394
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10204
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11892
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8523
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7671
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6475
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5220
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3813
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.