13

I have been looking for a way to make a "package folder" in visual studio express 2013, the way I might do it in java is a "package" I know that I can make whole new projects called "Visual Studio Package Projects" via a wizards but all I really want is a ~container~ that puts a dot in the class name! A folder by any other name!

THIS IS WHAT I AM LOOKING FOR

enter image description here

THIS IS WHAT I AM PRESENTED WITH

enter image description here

3 Answers 3

14

If you create class inside folder, the namespace (which is almost the same as packages in Java) for this class is based on the folder(s) it is inside.

Actually, packages in java are folders too.

Sign up to request clarification or add additional context in comments.

4 Comments

hmm I was afraid of that, are there any VSE2013 UI addons that you are aware of that can make these folders "stand apart" from the auto generated project folders?
@MrHeelis - I am not sure, what are you asking about. You can have namespace independent on the folder it is in, but why the hell you would ever want that? :D
I am referring to whether you can change the default folder icon in the solution explorer
In Java, we can run the package alone by having a main method in that, just to execute that part. Can we do that in C#?
10

Just add a new folder - then by default, new classes will be in that namespace. So for example, if you have a project called Foo, and you add a folder called Bar, then you'll end up with:

namespace Foo.Bar
{
}

at the top of classes in that folder. Namespaces are the closest C# has to Java packages. They're not quite the same, as packages in Java also affect access control - but they're close.

Comments

1

A folder can be created in a project root. And any number of nested folder can be created to categories common files. And intended class can be placed inside that folder. This way you can get ~container~ that puts . in namespace used in class.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.