473,473 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

question about inheritance and Imports statement

Does a subclass have to import namespaces which were already imported by the
superclass?

I have a base class which imports the System.Data.SQLClient namespace to use
the dataset member.

When I inherit this base class, the subclass must also import the
System.Data.SQLClient namespace to use its members.

I thought that a subclass would not have to re-import namespaces which were
already imported by the superclass.

Do I understand correctly, or am I doing something wrong?

Thanks
Bill
Nov 15 '06 #1
4 1737
If you go to your project properties -References, you can import the
reference for the entire project, rather than doing it on a file by file
basis.

"BillE" <be****@datamti.comwrote in message
news:eF**************@TK2MSFTNGP02.phx.gbl...
Does a subclass have to import namespaces which were already imported by
the superclass?

I have a base class which imports the System.Data.SQLClient namespace to
use the dataset member.

When I inherit this base class, the subclass must also import the
System.Data.SQLClient namespace to use its members.

I thought that a subclass would not have to re-import namespaces which
were already imported by the superclass.

Do I understand correctly, or am I doing something wrong?

Thanks
Bill


Nov 15 '06 #2
Robinson wrote:
If you go to your project properties -References, you can import the
reference for the entire project, rather than doing it on a file by file
basis.

You cannot use the Imports statement without first adding a reference
to the corresponding assembly. In other words you cannot add a
reference on a file by file basis. References are *always* added a
project level.

That said, the Imports statement has nothing to do with inheritance.
It is simply a means of easing the amount of typing a developer has to
do. Internally, the compiler works with the fully qualified type name.
>
"BillE" <be****@datamti.comwrote in message
news:eF**************@TK2MSFTNGP02.phx.gbl...
Does a subclass have to import namespaces which were already imported by
the superclass?

I have a base class which imports the System.Data.SQLClient namespace to
use the dataset member.

When I inherit this base class, the subclass must also import the
System.Data.SQLClient namespace to use its members.

I thought that a subclass would not have to re-import namespaces which
were already imported by the superclass.

Do I understand correctly, or am I doing something wrong?

Thanks
Bill
Nov 15 '06 #3
You cannot use the Imports statement without first adding a reference
to the corresponding assembly. In other words you cannot add a
reference on a file by file basis. References are *always* added a
project level.

That said, the Imports statement has nothing to do with inheritance.
It is simply a means of easing the amount of typing a developer has to
do. Internally, the compiler works with the fully qualified type name.
Yes, but you can add a reference to the assembly AND import the namespace in
project settings.
Nov 15 '06 #4

Robinson wrote:
You cannot use the Imports statement without first adding a reference
to the corresponding assembly. In other words you cannot add a
reference on a file by file basis. References are *always* added a
project level.

That said, the Imports statement has nothing to do with inheritance.
It is simply a means of easing the amount of typing a developer has to
do. Internally, the compiler works with the fully qualified type name.

Yes, but you can add a reference to the assembly AND import the namespace in
project settings.
Ah yes! Your first post said "References" so I was thinking about
adding a reference to another assembly, when you were actually
referring to the References section in the properties page and the
Imported Namespaces section on that.

I primarily use C# which does not have this feature, hence my
puzzlement.

Nov 15 '06 #5

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

Similar topics

1
by: Michael | last post by:
Hello, I'm trying to implement sample I found on page templates, so I do not have to maintain "<html><head>..." on all my documents. But don't let that confuse you, this is an inheritance...
2
by: John Boers | last post by:
I am trying to create a template for my website. But I have a problem, the system says BC30469: Reference to a non-shared member requires an object reference and points to the statement...
3
by: Chris Kennedy | last post by:
What's the difference between importing a namespaces and inheriting.
4
by: Jeff Jarrell | last post by:
I am not really there yet with namespaces. I have a "common.dll" that is referenced from another project. now in the consuming project, source file to i'd like to have a "imports common". ...
1
by: John | last post by:
Hi, Maybe someone can help me with the following: "The first task by any derived class constructor is to call it’s direct or indirect base class constructor implicitly or explicitly", reads the...
4
by: Mike W | last post by:
I have a class that requires the Imports System.IO statement to function properly. I intend on reusing this code in the future. I have another class in the project also need the system.io...
3
by: Ina | last post by:
Hello all, I am newbien in VB.net and I would like to know what is going wrong with my code. Imports System Imports System.Data Imports System.Data.SqlClient
5
by: kimiraikkonen | last post by:
Hello, I want to ask about "imports" statement. Some projects must be inserted with "imports xxxx" statements before beginning coding. But how do i know when to use or do i have to use "imports"...
11
by: Simon Woods | last post by:
Hi I have this recursive function and I want to walk the inheritance hierarchy to set field values .... the generic T is constrainted as the base class of the inheritance hierarchy Friend...
0
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,...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
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...
0
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...
0
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...
0
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 ...
0
muto222
php
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.