Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ide including path in namespace when at class creation
Message
General information
Forum:
ASP.NET
Category:
Visual Studio
Environment versions
Environment:
C# 5.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01603252
Message ID:
01603268
Views:
51
I remember being annoyed by this but eventually decided to 'go with the flow' and now find the way it works more intuitively. If you *really* don't like it there are a couple more options:

You can right click on the folder and 'Add/New From Template' which will use the root namespace.

You can create your own class template for the project. Bit more work but you can maybe add other useful bits (e.g. I put in pre-defined regions for Properties etc). See : http://msdn.microsoft.com/en-us/library/ms247121.aspx

>Thanks Viv.
>
>I guess a) is for people (unlike me yet) who have decided how to structure their project. So I'll go with b) or just edit the namespace.
>
>And yes, I will try resharper.
>
>>>Update : in VB it does not create such a namespace, which explains why I was not bothered. :)
>>>
>>>When I create a new class the ide generates a namespace that includes the path. For example, my project is D030, I created a folder duedates, then when I create a new class the IDE generates the namespace D030.duedates.
>>>
>>>Is that a "feature"? Can I change that behaviour?
>>
>>Three options:
>>
>>(a) Go with it. In practice it makes it easier to find files if their namespace matches the folder name (think a while about why you would want separate folders in the same namespace)
>>
>>(b) If you don't fancy (a) then create the class in the parent folder and then drag it to the sub folder.
>>
>>(c) If you use Resharper then there is a 'NameSpace Provider' option in the folder properties. If you set it to false then VS still puts the folder name in the namespace but Resharper fixes it with one click....
Previous
Reply
Map
View

Click here to load this message in the networking platform