|
|
||||||
|
#1
|
|
|
|
|
Does anyone know how to incorporate classes with different namespaces within
a project? I have two classes with the same name but different namespace. When I try to add the the second class of the same name the Visual Studio NET IDE blocks my attempt and asks whether I want to overwrite the first class. Which I do not want to do. Compiling is fine outside the IDE. |
|
|
|
#2
|
|
|
|
|
Hey,
I do not think this is possible, because you have 2 files with the same name in the same directory. The namespace is only of importance in the file itself. So rename the file, or put it in a subdirectory. Greetz, -- Rob. Jan Michalski wrote: [..] |
|
#3
|
|
|
|
|
Dear Rob,
Thanks for responding to this. I have a C# file which contains the main function and two classes with the same name within that same file. The classes have different namespaces. This file and another associated with it compile outside the Visual Studio IDE. I could not figure out how that file could be accommodated within the Visual Studio NET IDE. I checked through the documentation but could not find anything that would get me on the right track. I suppose what I am interested in is how I can incorporate code from different namespaces into my code. Within java this is easily done in the various IDEs. But with Visual Studio IDE I cannot quite figure this out. Regards, Jan "Rob Tillie" <Rob.Tillie> wrote in message news:a652 [..] |
|
#4
|
|
|
|
|
Dear Michael,
The file structure I have is the same as yours. Can you briefly outline how you incorporate this file into your project.When I create my project it automatically creates a namespace with the same name as the project name. And I cannot see how to incorporate further namespaces. I have tried to add two classes with the same name but different namespaces. And then the IDE protests. Clearly this approach must be incorrect. How do you do it? Regards, Jan "Michael Mayer" <mrmayer> wrote in message news:2236 [..] |
|
#5
|
|
|
|
|
As a preface, I don't think it's very good organization to have
mutliple classes in the same text file. I would try separating them out by directory, something like this: ProjectDirectory Source Namespace1 Class1.cs Namespace2 Class1.cs Bin Doc you get the idea... But if you do wish to put two classes into the same file, here's what I did: The way I did it originally was just to type the 2nd namespace into the default Class1.cs file of the project, and then compile it. Is this what you are doing? How does the IDE protest? When you compile? If you have a file called Class1.cs with two classes in it (like my previous post) I can add it to a new project (one that does not have a Class1.cs) as follows: In solution explorer: Right click on the project name: Add existing item Pick Class1.cs from the dialog It adds it just fine. Also, I can add a new class into an existing file with the wizard. Goto class view. You'll see the namespaces. You can add a third class into the file: Right click on the project Add | class Enter the following: Class: Class1, Namespace: Namespace3 Hit ok It prompts me: Class1.cs already exists. Do you want to merge to it? I hit yes. mike "Jan Michalski" <jan.michalski> wrote in message news:4305 > Dear Michael, > > The file structure I have is the same as yours. > > Can you briefly outline how you incorporate this file into your > project.When I create my project it automatically creates a namespace with > the same name as the project name. And I cannot see how to incorporate > further namespaces. I have tried to add two classes with the same name but > different namespaces. And then the IDE protests. Clearly this approach must [..] |
|
|
| Similar Threads | |
| Visual Studio generated namespaces VS 2005: If I create a folder in my project, when I add new classes to that folder, VS generates a namespace which is the project default namespace concatenated with the... |
|
| Where to get the Sharepoint Namespaces for Visual Studio .NETdevelopment I've install wss 3.0 and MOSS 2007 SDKs on my client. And VS 2005 Sharepoint extensions appear to be a server install. Still no sign of the SharePoint Namesspaces... |
|
| How to take an IE rendered screenshot of a website with visual studio .net 2002 or visual stuido .net 2003? I can't install visual studio .net 2005 on this computer. How to take an IE rendered screenshot of a website with visual studio .net 2002 or visual stuido .net 2003? I can't install visual studio .net 2005 on this computer. |
|
| Visual Studio Code Analysis using namespaces Is it possible to run Code Analysis in VS for a specific namespace (or class) ? I used to work with the FxCop UI where I could specify which namespaces to analyze. Now I am... |
|
| Namespaces not visible in Visual Studio 2003 developing with C# I have a .Net Windows Forms application made up of several projects. Under one project, I added a new folder under my GUI project called 'Components'. I am going to add... |
|
|
All times are GMT. The time now is 01:34 AM. | Privacy Policy
|