?
Solved

Help clarifying a textbook example project

Posted on 2006-07-11
4
Medium Priority
?
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 17082353
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
ID: 17082383
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 1000 total points
ID: 17082496
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
ID: 17082526
Thanx! :^)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

770 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