【发布时间】:2010-11-17 23:38:28
【问题描述】:
我有一个有一定长度的程序,有一个类和许多方法。所有这些都必须包含在一个巨大的类中,该类包含除了 using 语句之外的整个文件。这么大的包装类的必要性似乎毫无意义,这只是在以后制作具有多个文件的程序时才使用吗?
using System;
using System.IO;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Linq;
public class CollectKeywordsFromLogs // why do I need this ( when it is the only class [as i just added the test class for the question])
{
//a class
//constructor
//methods
//methods
public static void Main() // and why would i need to explicitly declare this public? it works either way, and a private main would be useless no?
{}
}
这是我的完整文件。我编译 csc file.cs 然后 file.exe。
哦,对,区分大小写。谢谢。但仍然 -> 为什么我在不使用测试类时需要包装类?
【问题讨论】:
-
我在这里看到了几个不同的问题,无法在一个线程中完全回答。您应该考虑将它们分开。
-
我同意 Rex 的观点,请清理并可能拆分您的问题。并且提供几行代码,比描述清楚多了。
-
只是为了确保我理解这个问题:你问为什么文件中的所有代码都包含在一个类中?你不是指在一个班级里有一个班级,对吧?只是问为什么一个文件包含一个类?
-
问。什么时候需要一个包装类? A. 当 Eminem 是你的老师时