473,804 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sub Class Namespace?

Hi,

Question (in short):
can i somehow use the namespace tag to define that a class in its own file
is actually the subclass (namespace wise) of another class?

Explanation:
for example, if I have one class named "Schema", this class should have a
public sub class named "Table", such as:

Namespace Test
Public Class Schema
Public Class Table
End Class
End Class
End Namespace

so that i could access it using: Test.Schema.Tab le

BUT I do not want the Schema and Table class to be defined in the same file!..
(even with regions etc it is still much harder too keep track of the classes
if they are all in the same file)

Elaboration:
the above example is just that, an example, i know that it wouldn't be so
bad to have two files in a sub namespace called Data for example (one for
Schema and one for Table).. the problem is however that i have created my own
global namespace which has a lot of sub namespaces but also a few select
classes, now these classes have sub classes (a specialized settings class for
example) but i put them into separate files to be able to keep better track
of everything.. that however brings with it the problem that now those
subclasses are appearing on the root my main namespace (along with their
logical parent classes) where they obviously don't belong… what to do?

help would be greatly appreciated to make this work!

Thanks!
Aug 1 '06 #1
4 1704
R. Nachtsturm wrote:
Hi,

Question (in short):
can i somehow use the namespace tag to define that a class in its own file
is actually the subclass (namespace wise) of another class?

Explanation:
for example, if I have one class named "Schema", this class should have a
public sub class named "Table", such as:

Namespace Test
Public Class Schema
Public Class Table
End Class
End Class
End Namespace

so that i could access it using: Test.Schema.Tab le

BUT I do not want the Schema and Table class to be defined in the same file!..
(even with regions etc it is still much harder too keep track of the classes
if they are all in the same file)
Using VB2005, you can have partial classes - this simply means that the
class definition is spread across more than one file. So you could have

(File1.vb)
Namespace Test
Partial Public Class Schema
Public Class Test

End Class
End Class
End Namespace

(File2.vb)
Namespace Test
Partial Public Class Schema
Public Sub New()

End Sub
End Class
End Namespace

Together, these two files define a single class Test.Schema, which
contains a class Test.

Before VB2005, you can't do anything like this.
--
Larry Lard
la*******@googl email.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Aug 1 '06 #2
R. Nachtsturm wrote:
Explanation:
for example, if I have one class named "Schema", this class should have a
public sub class named "Table", such as:

Namespace Test
Public Class Schema
Public Class Table
End Class
End Class
End Namespace
Do you really intend a sub class? Normally the term 'subclass'
actually refers to a derived class. What you have declared here is a
nested class which is not quite the same thing.

Larry has already shown you how to use partial classes. But if you
really mean a derived class, then you don't need a partial class:
'File #1
Namespace Test
Public Class Schema
End Class
End Namespace
'File #2
Namespace Test
Public Class Test
Inherits Schema
End Class
End Namespace

Aug 1 '06 #3
Thanks for the help!

Yes, my mistake, i meant a nested class, not a derived one :)

so Partial Classes is what i was looking for!
"Chris Dunaway" wrote:
R. Nachtsturm wrote:
Explanation:
for example, if I have one class named "Schema", this class should have a
public sub class named "Table", such as:

Namespace Test
Public Class Schema
Public Class Table
End Class
End Class
End Namespace

Do you really intend a sub class? Normally the term 'subclass'
actually refers to a derived class. What you have declared here is a
nested class which is not quite the same thing.

Larry has already shown you how to use partial classes. But if you
really mean a derived class, then you don't need a partial class:
'File #1
Namespace Test
Public Class Schema
End Class
End Namespace
'File #2
Namespace Test
Public Class Test
Inherits Schema
End Class
End Namespace

Aug 1 '06 #4
Thank you so very much!

that was exactly what i was looking for!

thank you!

"Larry Lard" wrote:
R. Nachtsturm wrote:
Hi,

Question (in short):
can i somehow use the namespace tag to define that a class in its own file
is actually the subclass (namespace wise) of another class?

Explanation:
for example, if I have one class named "Schema", this class should have a
public sub class named "Table", such as:

Namespace Test
Public Class Schema
Public Class Table
End Class
End Class
End Namespace

so that i could access it using: Test.Schema.Tab le

BUT I do not want the Schema and Table class to be defined in the same file!..
(even with regions etc it is still much harder too keep track of the classes
if they are all in the same file)

Using VB2005, you can have partial classes - this simply means that the
class definition is spread across more than one file. So you could have

(File1.vb)
Namespace Test
Partial Public Class Schema
Public Class Test

End Class
End Class
End Namespace

(File2.vb)
Namespace Test
Partial Public Class Schema
Public Sub New()

End Sub
End Class
End Namespace

Together, these two files define a single class Test.Schema, which
contains a class Test.

Before VB2005, you can't do anything like this.
--
Larry Lard
la*******@googl email.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Aug 1 '06 #5

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

Similar topics

4
3828
by: marco_segurini | last post by:
Hi, the following test program shows a solution to a problem I have had. Now, this test program is compiled and linked by VS2003 and g++ while Comeau-on-line-compiler fails with this messages: "ComeauTest.c", line 21: error: constant "COuter::ID" is inaccessible int i = COuter::ID; ^
0
3030
by: keith bannister via .NET 247 | last post by:
(Type your message here) -------------------------------- From: keith bannister Hi, I'm new to .net (as of last week) but here goes. I want to serialize/deserialize a file the conforms to an XML schema (xsd).
5
7288
by: Keith Bannister | last post by:
I'm new to .net so here goes. I'm tying to deserialize a class that is associated with an XML schema. I created the C# class with xsd.exe as below: xsd.exe /c /n:somenamespace properties.xsd this creates properties.cs
14
1991
by: Lee Franke | last post by:
I can't seem to figure this one out. Here is my class structure namespace name { public class foo { } }
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?)
16
2385
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...
5
5487
by: Marcin Gil | last post by:
Hi! I have the code like this (obvious things like ctor/dtor removed) typedef struct _NODE { int val; int index; } Node;
9
6487
by: Mark Olbert | last post by:
I'm trying to serialize (using XmlSerializer.Serialize) a class that I generated from an XSD schema using XSD.EXE /c. The problem I'm running into is that the root element needs to be unqualified, and the default namespace needs to be included on it as an attribute. The schema I'm using is this: <xs:schema xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:html="http://www.w3.org/TR/REC-html40"...
6
369
by: Nikola | last post by:
Is it possible in C++ to create a class hierarchy by inheritance that spans across various namespaces? For example, say I want to create a class which would behave like object type in C#, so that all classes I have would be below it in inheritance hierarchy, but my classes are scattered throughout various namespaces. Say I have 2 classes in namespace A and 2 in namespace B, where namespace A and namespace B are not related, and now I...
0
10604
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...
0
10354
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...
0
9177
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6870
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
5536
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
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
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
3837
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3005
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.