473,591 Members | 2,908 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 1690
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
3811
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
3020
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
7278
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
1961
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
3403
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
2351
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
5474
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
6466
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
7934
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
7870
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
6639
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...
1
5732
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
5400
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
3850
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...
1
2378
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
1
1465
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1199
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.