PDA

Click to See Complete Forum and Search --> : [RESOLVED] NameSpaces


Arc
Jul 7th, 2007, 07:39 PM
I am completely confused by namespaces.

First of all, how do I change the namespace for my overall project. i tried to do it manualy, but then I get tons of errors.

Secondly, I added a new form and incorperated some of the same "Using" files, and I keep getting errors saying these files are already in use by this namespace.

Does each form need a different namspace? Or do I only need to declare the imported files in the main form and that is it?

In other words.. I am getting errors saying that i have already declared Sytem.IO in another form, for example. Is that normal?

Woah is me....:(

nmadd
Jul 7th, 2007, 08:59 PM
Hi there,

Here's the little I know:

You can change your project's default namespace in Project->Properties->Application(tab)

Each form needs its own using statements. A form is just another class. Each form does not need its own namespace. When you add a new form to your project, you'll see that as a default it gets its own using statements above the namespace and all your code is within your project's default namespace.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MyProgram
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

I also think that this is a helpful definition of namespace: http://en.wikipedia.org/wiki/Namespace_(computer_science)

I hope that little helps. ;)

ComputerJy
Jul 7th, 2007, 11:29 PM
Note that when you change the namespace of your application you might see a couple of warnings and errors, try to clean and rebuild your project. This will probably eliminate them

Arc
Jul 9th, 2007, 10:30 PM
Thanks guys, I appreciate it.