开发者

VB.NET Project Folder Question

开发者 https://www.devze.com 2023-03-15 15:16 出处:网络
So if I am working on a project in VB.net (really any visual studio project), I am able to create folders.My project is getting rather unweildy (over 30 classes) and I think it would be beneficial to

So if I am working on a project in VB.net (really any visual studio project), I am able to create folders. My project is getting rather unweildy (over 30 classes) and I think it would be beneficial to store for example data structure classes in a folder "ds" and user controls in a folder "uc". Is this OK? Will it affect the way I reference the classes? Are the folders simply for my own use and structure or do they actual开发者_开发百科ly have some kind of impact on my project as a whole?

PS in case you are confused, I am referring to the structure shown in the "Solution Explorer". Sorry if this is a dumb question or not clear, but I have never worked on a large project like this before.


There's no such thing as dumb questions. ;) You can do this, but do yourself a favor and keep your namespaces the same as your folder hierarchy or you can end up with a bird's nest pretty quickly. For example, if the project's default namespace is MyProject and the folder is Dc, those classes should be in

Namespace MyProject.Dc

Edit: Just wrap your classes to mirror your folder structure like:

Namespace MyProject.Ds
    Module MyModule

        Sub Main()
            'do stuff here
        End Sub

    End Module
End Namespace


Adding the folders will default the namespace of any newly added files into those folders to include the folder name. For example MyApp.UC or MyApp.DS.

Creating a folder and moving your user controls, data structures etc. shouldn't be a problem.

You can always test this on a new Test Project - that's my usual way :)


You can use folders for everything. I do it all the time, you just need to include the folders name when accessing it.

VB.NET Project Folder Question

So if I wanted to call something in the Exceptions folder, I would use Exceptions.DialogExceptionEdit, etc.


Adding a new Folder shouldn't change anything in your project, if you are careful about the namespaces they are in and also being careful while referring to Class files using their path.

0

精彩评论

暂无评论...
验证码 换一张
取 消