Solved

Help clarifying a textbook example project

Posted on 2006-07-11
4
216 Views
Last Modified: 2010-04-23
I have been studying creating custom user controls, and am about to start the "Hands-on" programming example.
However, it's as if it's introducing a new feature that wasn't explained in the text.  Could someone clarify what is meant by changing the root namespace in the following:

"Create a Windows user control that ... <blah> <blah> <blah>
This control must make the data ... available to the form...
To share a Person structure between the control and the form, each project must be declared in the same namespace.  By default, each project is created in its own root namespace.  The easiest and best way to change this is to display the Project Properties dialog box and change the root namespace before building the project."

So - why exactly is changing the namespace necessary?  
And what exactly would one change it to?
0
Comment
Question by:sirbounty
  • 2
  • 2
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
They're basically saying that your UserControl and your Test Harness project should both be in the same namespace, presumably to simplify the example.

You can change it to whatever you want, just so long as they are the same. So, for example, you might have a line like:

    Namespace MyProject.UserControlSample

At the top of your UserControl class and the form in your test harness project.
0
 
LVL 67

Author Comment

by:sirbounty
Comment Utility
Hmm - maybe my ignorance stems from the usage of 'namespace'.  What is it and how's it used in my project(s)?

Why would they need to share the same namespace and/or what would be the limitation(s) if they did not?
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 250 total points
Comment Utility
Namespaces are simply a way of grouping related objects, they are also used to avoid clashes in object names.

So, if you have two classes both called "Person", if they were in the same namespace then if you used something like:

    Dim p As New Person()

Then the compiler wouldn't know which Person class you meant. However, if you seperate them into seperate namespaces:

    Namespace Customers
        Class Person
        End Class
    End Namespace

    Namespace Contacts
        Class Person
        End Class
    End Namespace

Then you could use:

    Dim p As New Customers.Person()         '// Explicitly state the namespace

Or:

    Imports Customers

    ....

    Dim p As new Person()          '// No need to explictly state namespace because we have "Imported" it


If they are in different namespaces then it just means that you have to Import the namespace in which the UserControl lives, whereas, if they are in the same namespace then you don't need to.
0
 
LVL 67

Author Comment

by:sirbounty
Comment Utility
Thanx! :^)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now