将您的代表放在哪里。 。

发布于 2024-07-09 04:07:08 字数 142 浏览 9 评论 0原文

我正在尝试确定我的应用程序的最佳目录结构

UI
数据
接口

,但我不知道在哪里放置委托。

是否应该有一个单独的委托文件夹,或者我应该将委托存储在使用它们的同一类中。 。

I am trying to determine the best directory structure of my application

i have:

UI
Data
Interfaces

but i dont know where to put delegates..

should there be a seperate Delegates folder or should i store the delegates in the same classes where they are being used . .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

永不分离 2024-07-16 04:07:09

如果您的委托有共同用途,则应该将它们存储在公共位置,但如果您仅在类中使用它,则将其放在同一个类中。

If you have an common use for your delegates, you should store them on a common place, but if you only use it in your class then put it in the same class.

热血少△年 2024-07-16 04:07:09

您没有 Classes、Structs 和 Enums 文件夹。 为什么要有 Delegates 文件夹?

另外,如果您使用 C# 3.0,则通常应该使用通用委托 - System.Action 和 System.Func - 而不是命名委托。

You don't have a Classes, Structs, and Enums folder. Why have a Delegates folder?

Also, if you're using C# 3.0, you generally should be using Generic Delegates - System.Action and System.Func - instead of named delegates.

猫性小仙女 2024-07-16 04:07:09

我认为这是一个坏主意。 您应该像 Microsoft 那样按功能对代码进行排序。

至于代表,你不再需要他们了。 现在我们已经有了通用的 Func 和 Action 委托,没有理由创建您自己的委托。

I think that's a bad idea. You should sort your code the same way Microsoft does, by functionality.

As for delegates, you don't need them any more. Now that we have the generic Func and Action delegates, there is no reason to create your own.

橘亓 2024-07-16 04:07:09

委托本质上是引用类型方法容器。 在我看来,您应该将委托存储在使用它们的同一类中。 无需创建单独的委托文件夹。

Delegates are essentially reference type method containers. In my opinion you should store the delegates in the same classes where they are being used. There is no need to create a separate delegate folder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文