About namespace

Hi, I am new to C#.

To create a new namespace, do we need to click any thing on the visual studio 2005 toolbar, or just simple rename the existing namespace to
namespace newname{


}

this is due to when I simple put a new name, it shows me "Options to update references to rename object".
What happen? What is the correct procedure to put a new namespace?
LVL 9
william007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

xPert_UmerCommented:
just rename it :)
0
william007Author Commented:
May I know rename what? I wish to create many namespaces...how to do that?
0
xPert_UmerCommented:
yeah.... bcoz the name space you are going to change is being used in other socurce code files... so it need to update all the reference in other code like
namespace myspace
{
 class  A  
  {
  public int a ;
  // some code here
  }
}
in other code file
{
myspace.A obj ;
A.i = 3 ;
}
some thing like dat
so it needs to update namespace references. as well.
0
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

william007Author Commented:
I see, so when I add a new namespace, in the solution explorer, will it show the namespace information? If no, where can we find it?
(Actually I just want to have a high level view of each file contain what namespace, instead of one my one open them)
0
xPert_UmerCommented:
well... i dont have VS now .. but i guess...

i think Class view explorer ll show you namespaces..

if the changed namespace is being used by any other sourcecode file then it ll show update option,else you can simply change..no update required.
0
icrCommented:
When you type "using System.Drawing" etc. System.Drawing is a namespace. When you write you're own namespace it is possible (and if you are working with a form, almost certain behind the scenes) that another file has got "using YourNamespaceHere" in it (or in the case of WinForms, the generated file needs to be in the same namespace) so it gives you the option to change those accordingly.

If you are changing the namespace of the main file you probably want to go into the project's Properties and change the default namespace accordingly, though I think the "Options to update references to rename object" might do this for you, not sure.

Other than that you can rename the namespace to what you want and just select to update other references usually.

As for information about a namespace, you want the Object Browser (it's under View->Other Windows in VS2005/8 Express and View in Standard and above)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JimBrandleyCommented:
Usually, the namespace corresponds to the assembly name. So if you add a new project to your solution, you are creating a new assembly, and with it a new namespace.

Jim
0
gbzhhuCommented:
For readibility of your namespaces I usually use the dot notation.  So in my solution I have say 4 assemblies with namespaces like this

Solution is called MobileCentaur

Then namespaces in assemblies

MobileCentaur.BusinessObjects                                
MobileCentaur.CentaurApp
MobileCentaur.DAL
MobileCentaur.CentaurSvc

Etc  That way your object relationships become clearer
0
william007Author Commented:
Thanks:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.