问题
In C# the method Main must be in a nongeneric type in order to be selected as entry point. Why is that?
I'm a little bit confused about that because that is possible in Java (the function main() can be in a generic class).
namespace ConsoleApplication
{
class Program<T> //incorrect
{
static void Main(string[] args)
{
}
}
}
回答1:
The Main
method serves as a fixed interface to the operating system, which itself has no mechanism to select and specify a type to be given as a parameter.
来源:https://stackoverflow.com/questions/28045923/why-i-cannot-use-as-entry-point-in-c-sharp-app-a-generic-type