470,631 Members | 1,704 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,631 developers. It's quick & easy.

Diff. B/w Imports & Inherits?

What's the difference between "Imports" & "Inherits"? For e.g. both the
codes below work without any errors:

Imports System
Imports System.Data
Imports System.Web.UI

Namespace Constructors
Public Class Constr : Inherits Page
Public Sub New()
Response.Write("Constructor1")
End Sub
End Class
End Namespace

----------

Imports System
Imports System.Data

Namespace Constructors
Public Class Constr : Inherits System.Web.UI.Page
Public Sub New()
Response.Write("Constructor1")
End Sub
End Class
End Namespace

In the first code snippet, I am importing "System.Web.UI" & then
inheriting the "Page" class where as in the second code snippet, I am
just inheriting "System.Web.UI.Page". So what's the difference between
importing & inheriting?

Thanks,

Arpan

Sep 20 '06 #1
1 1378
Imports just allows you to not have to type out the namespace that
contains the class every single time. So, by declaring Imports
System.Web.UI, and then doing Page, it knows which class you want,
without using the Imports statement, you would have to type out
System.Web.UI.Page everytime.

the "Inherits" keyword is completely unrelated. This has to do with
Object Oriented Programming and one of its many features. Search for
OOP on wikipedia.org, as this topic as a whole is out of the scope of
this thread.

Hope this helps!

Sean

Arpan wrote:
What's the difference between "Imports" & "Inherits"? For e.g. both the
codes below work without any errors:

Imports System
Imports System.Data
Imports System.Web.UI

Namespace Constructors
Public Class Constr : Inherits Page
Public Sub New()
Response.Write("Constructor1")
End Sub
End Class
End Namespace

----------

Imports System
Imports System.Data

Namespace Constructors
Public Class Constr : Inherits System.Web.UI.Page
Public Sub New()
Response.Write("Constructor1")
End Sub
End Class
End Namespace

In the first code snippet, I am importing "System.Web.UI" & then
inheriting the "Page" class where as in the second code snippet, I am
just inheriting "System.Web.UI.Page". So what's the difference between
importing & inheriting?

Thanks,

Arpan
Sep 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Ching-Lung | last post: by
reply views Thread by Rob Meade | last post: by
2 posts views Thread by Shapper | last post: by
5 posts views Thread by Shapper | last post: by
5 posts views Thread by Supra | last post: by
2 posts views Thread by danthman | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.