473,769 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating Your own Namespace...

Something thats been bugging me for a while...

how do you create a namespace that has many children (namespaces)

I.e system.io.blah. blah

Iv'e done it by creating a class which contains another class.

i can see the properties of the first class and the namespace of the second
(inner class) but can't see the properties of the 2nd....

This might not have been put very well........... .
Nov 20 '05 #1
8 9091
Thus spake Simon Edwards:
how do you create a namespace that has many children (namespaces)


Just specify the desired namespace in each file:

(File A)
namespace MyUtilityLibrar y.Data

(File B)
namespace MyUtilityLibrar y.Data.Sql

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
Nov 20 '05 #2
Ok i've put something together as an example...

Public Class Test1

Public ReadOnly Property test1_prop()

Get

End Get

End Property

Public Class Test2

Public ReadOnly Property test2_prop()

Get

End Get

End Property

End Class

End Class

The above when insntaned will let you see the test1 property and the test 2
class but not thye test2 property?

i want to build my own classes with a structure similar to how dot net works
with its namespaces

fr****@acadx.co m> wrote in message
news:eI******** ******@TK2MSFTN GP10.phx.gbl...
Thus spake Simon Edwards:
how do you create a namespace that has many children (namespaces)


Just specify the desired namespace in each file:

(File A)
namespace MyUtilityLibrar y.Data

(File B)
namespace MyUtilityLibrar y.Data.Sql

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com

Nov 20 '05 #3
Hello,

"Simon Edwards" <si************ @hotmail.com> schrieb:
how do you create a namespace that has many children
(namespaces)

I.e system.io.blah. blah

Iv'e done it by creating a class which contains another class.

i can see the properties of the first class and the namespace of the second (inner class) but can't see the properties of the 2nd....

This might not have been put very well........... .


\\\
Namespace Bla
Namespace Foo
...
End Namespace

Namespace Gac
...
End Namespace
End Namespace

Namespace Moo
...
End Namespace

Namespace Moo.Baz
...
End Namespace

Namespace Moo.Goo
...
End Namespace
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #4
Thus spake Simon Edwards:
i want to build my own classes with a structure similar to how dot
net works with its namespaces


Your example shows nested classes, not namespaces. Typically, a nested
class is meant for use only within its parent class. Namespaces are
simply organizational units.

Let's say you have a console application project with three files. The
first one we'll leave alone. In the second one, change the namespace to
MyConsoleApp.Bl ah. in the third one, change the namespace to
MyConsoleApp.Bl ah.Blah.

Now go back to the first file and add a pair of using directives:

using MyConsoleApp.Bl ah;
using MyConsoleApp.Bl ah.Blah.

See how the IntelliSense pops out? Now that you have multiple
namespaces, you can use them to organize your classes as you see fit.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
Nov 20 '05 #5
Hello,

"Simon Edwards" <si************ @hotmail.com> schrieb:
Ok i've put something together as an example...

Public Class Test1

Public ReadOnly Property test1_prop()

Get

End Get

End Property

Public Class Test2

Public ReadOnly Property test2_prop()

Get

End Get

End Property

End Class

End Class

The above when insntaned will let you see the test1
property and the test 2 class but not thye test2 property?

i want to build my own classes with a structure similar to
how dot net works with its namespaces


Classes are different from namespaces. Are you sure you understand the
difference between them? If you don't understand it, I would suggest to
have a quick look at the VB.NET documentation. Your sample shows a
declaration of a class inside a class, this has nothing to do with
namespaces.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #6
Hi Simon,

Namespaces are for differentiating between classes (and other entities)
which have the same name.

Consider:
Namespace Edwards
Class Simon
End Class
End Namespace

Namespace Jones
Class Simon
End Class
End Namespace

Now, somewhere else, I want to create an instance of a Simon.
Dim MyMan As Simon

This will fail, however, - the compiler complaining that there is a choice
of two.

I have to qualify it with the appropriate namespace.
Dim MyMan As Edwards.Simon

This will work and that, simplified, is what namespaces are for.

=============== =============== =
Nested classes are for when you need the facilities that a class provides
but only for the exclusive use of the outer class. This is not as common a
situation as you seem to be implying. Usually the inner class will be Private
or Protected. If it is going to be Public, there's little point in having it
nested.

Public Class clsOuter
Public OuterField As New clsInner
Public Class clsInner
Public InnerField As Integer = 3
End Class
End Class

Somewhere you declare an instance of the outer class:
Dim oFoo As clsOuter

This will create an instance of clsInner for itself and that will set its
InnerField to 3.

With oFoo you can access OuterField but not InnerField.
With oFoo.OuterField you can access InnerField.

=============== =============== =
Usually you have the inner class as Private and expose it indirectly using
Properties.

Public Class clsOuter
Private MyInner As New clsInner
Public ReadOnly Property OuterProp As Integer
Get
Return MyInner.InnerFi eld
End Get
End Property
Private Class clsInner
Public InnerField As Integer = 3
End Class
End Class

Somewhere you declare an instance of the outer class:
Dim oFoo As clsOuter

This will again create an instance of clsInner for itself whiich will set
its InnerField to 3.

With oFoo you can only access OuterProp which will give you InnerField's
value.

=============== =============== =
I'm intrigued - can you tell us more about this hierarchy that you want to
build ?

Regards,
Fergus
Nov 20 '05 #7
I am only using C#, but I assume this works the same way in VB.NET; The
answer applies to projects in visual studio.net.

You may change the default namespace of your project by using the properties
on the project; right-click the project-name, select "properties ", find
"default namespace". Here you may want to change from the "project-name"
(which is the normal) to "company.projec t" or something.

Further, by creating subdirectories in the project folder, the namespace for
new elements will default to the default namespace-name of elements in the
parent directory + the name of the directory.

You may also change the namespace manually using the namespace-statement;
this is what automatically happens using the methods mentioned above.

What I think would be normal with regards to namespace; would be to make
library-projects with sensible namespaces for what library it is;
company.control s.winforms company.net.smt p; and such; and in the main
program just use the default namespace. You may want to subdivide some
libraries, then you would use folders to create new namespaces.

Regards,

Harald Bjorøy
www.ulriken-consulting.no
"Simon Edwards" <si************ @hotmail.com> wrote in message
news:10******** *******@ananke. eclipse.net.uk. ..
Ok i've put something together as an example...

Public Class Test1

Public ReadOnly Property test1_prop()

Get

End Get

End Property

Public Class Test2

Public ReadOnly Property test2_prop()

Get

End Get

End Property

End Class

End Class

The above when insntaned will let you see the test1 property and the test 2 class but not thye test2 property?

i want to build my own classes with a structure similar to how dot net works with its namespaces

fr****@acadx.co m> wrote in message
news:eI******** ******@TK2MSFTN GP10.phx.gbl...
Thus spake Simon Edwards:
how do you create a namespace that has many children (namespaces)


Just specify the desired namespace in each file:

(File A)
namespace MyUtilityLibrar y.Data

(File B)
namespace MyUtilityLibrar y.Data.Sql

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com


Nov 20 '05 #8
Quick overview: Namespaces are used to organize and differentiate classes,
structures and other types. Declaring nested classes will allow you to
organize your classes, but you'll have troubles when you need to create
instances of the classes. Namespaces have little overhead and are more
purely for organizational purposes.

Check out the documentation at:
http://msdn.microsoft.com/library/de...us/vblr7/html/
vastmNamespace. asp
The frameworks classes are organized using namespace statements like the
following:

Namespace System

Namespace IO
Class Steam
End Class

Class File
End Class
End Namespace

Namespace Data
Class Connection
End Class
End Namespace
End Namespace

However, the Namespace statement in VB has a trick that will save you a
lot of typing: you can declare multiple nested namespaces in one Namespace
statement by using the "." to separate nested namespaces.

The following declaration declares three namespaces, System, IO, and
Stream, one nested within the other

NameSpace System.IO.Strea m
Class Test
End Class
End Namespace

This is equivalent to

Namespace System
Namespace IO
Namespace Stream
Class Test
End Class
End Namespace
End Namespace
End Namespace
--------------------
From: "Simon Edwards" <si************ @hotmail.com>
Subject: Creating Your own Namespace...
Date: Fri, 19 Sep 2003 22:59:11 +0100
Lines: 14
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Organization : Ye 'Ol Disorganized NNTPCache groupie
Message-ID: <10************ **@ananke.eclip se.net.uk>
Cache-Post-Path: an************* **************@ 81.168.16.121
X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/)
Newsgroups: microsoft.publi c.dotnet.framew ork,microsoft.p ublic.dotnet.fr amework.interop ,
microsoft.publi c.dotnet.framew ork.wmi,microso ft.public.dotne t.general,micro s
oft.public.dotn et.languages.vbNNTP-Posting-Host: ananke.eclipse. net.uk 212.104.129.36
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP11.phx.g bl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.interop:189 14 microsoft.publi c.dotnet.framew ork.wmi:76
microsoft.publi c.dotnet.genera l:109235
microsoft.publi c.dotnet.langua ges.vb:139641
microsoft.publi c.dotnet.framew ork:54250X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb

Something thats been bugging me for a while...

how do you create a namespace that has many children (namespaces)

I.e system.io.blah. blah

Iv'e done it by creating a class which contains another class.

i can see the properties of the first class and the namespace of the second
(inner class) but can't see the properties of the 2nd....

This might not have been put very well........... .


Nov 20 '05 #9

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

Similar topics

7
8437
by: Simon Edwards | last post by:
Something thats been bugging me for a while... how do you create a namespace that has many children (namespaces) I.e system.io.blah.blah Iv'e done it by creating a class which contains another class. i can see the properties of the first class and the namespace of the second (inner class) but can't see the properties of the 2nd....
1
1451
by: dhnriverside | last post by:
Hi peeps I want to create some namespaces and dlls to encapsulate some common functionality. Here's what I want. Me Me.CompanyA Me.CompanyA.BusinessObjects Me.CompanyB. Me.CompanyB.BusinessObjects
6
3412
by: ryan.d.rembaum | last post by:
Hello, I have code that I wish to use in many web applications. Basically sort of stand utility stuff. So from Visual Studio Project I select add a component and chose Component Class. Lets say I enter code at the end of this question in to the code section. How then would I reference this in a new Web Application (or in the same web application for that matter?)
3
1603
by: Garth Wells | last post by:
used the following "classic ASP" approach to build a dynamic menu, but would like to know the proper way to implement the same functionality using a .Net technique (e.g., placing the code in the .cs file and dynamically building the hyperlink controls). The controls need to appear within the same <TD>, separated by two spaces Thanks for your help -----
16
2380
by: tshad | last post by:
This is a little complicated to explain but I have some web services on a machine that work great. The problem is that I have run into a situation where I need to set up my program to access one or another (could also be 3) different web servers to use these Web Services. The Web Services are identical on all the machines. I tried just changing the URL of the Web Services and cannot make it work. I then decided to create 2 identical web...
4
2756
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. It should put a blue and yellow box on the page with "This is a test" as part of the picture. But what I get is a broken Gif. The other problem is that I can't view the source???? The view source is disabled for this page. What causes this?
13
11285
by: LordHog | last post by:
Hello all, I have a little application that needs to poll a device (CAN communications) every 10 to 15 ms otherwise the hardware buffer might overflow when there are message burst on the bus. I would implement an interrupt driven model, but the external device (which is connected via USB) does not support interrupts therefore the device needs to be polled at a specific interval. So my question is how can I implement a "deterministic"...
2
2661
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i need to read in a text file... shown below H H,E,L E,B,F B,A,C A,null,null
0
6111
by: austincolby | last post by:
I am working on creating a SOAP client in Visual Studio 2008 for the first time but am running into a few issues. I added the Web Service reference to the project and am able to see the namespace and set the information for the classes but cannot figure out how to send the information to the server or receive a response. Below is my code and any help is appreciated! Imports Microsoft.Web.Services2 Public Class Form1 Public...
0
9422
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
10038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7404
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
6662
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
5294
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
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
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
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.