C#可以部分类"计划"类控制台应用程序? [英] C# Possible to partial class "program" class for a console application?

查看:123
本文介绍了C#可以部分类"计划"类控制台应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,如果有可能改变这种状况得到任何控制台应用程序的部分类创建默认的程序类。

I was wondering if its possible to change the default "program" class that gets created for any console application to a partial class.

我想这样做,因为我想更好的组织,而不是在按地区分类1文件中的所有方法。它会更有意义,让我有一定的方法分类坐在单独的文件。

I want to do this because I want better organisation rather than have all methods in 1 file categorized by region. It would make more sense for me to have certain method categories sitting in separate files.

我的一个分部类的理解是,它是在编译过程中融合了类文件复制到1级的单元多个文件的类定义。

My understanding of a partial class is that it is a class definition in multiple files that during a compile merges the class files into 1 class unit.

我可能是错的,或者有可能是我取得更好的组织结构,更好的办法。任何建议将帮助,并感谢

I could be wrong, or there could be a better way for me to achieve better organisational structure. Any suggestions would help, and thanks

推荐答案

您肯定的可以的做到这一点 - 但它听起来像你对我会更好的分割code成多类。如果你有多个方法类别这些类别可能是天然的阶级界限。

You certainly can do that - but it sounds to me like you'd be better off splitting your code into multiple classes. If you've got multiple method "categories" those categories may well be natural class boundaries.

一般来说,入口点类应该是相当小的。这并非总是如此,但它是一个很好的经验法则。通常它的唯一目的是让程序运行的剩余部分。

Generally speaking, the entry point class should be fairly small. That's not always the case, but it's a good rule of thumb. Usually its only purpose is to get the rest of the program running.

这篇关于C#可以部分类"计划"类控制台应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆