为什么我不能在C#应用程序中使用泛型类型的入口点? [英] Why I cannot use as entry point in C# app a generic type?
本文介绍了为什么我不能在C#应用程序中使用泛型类型的入口点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对此有点困惑,因为这在Java中是可能的(函数main()可以在泛型类中)。
命名空间ConsoleApplication
{
class Program< T> //不正确的
{
static void Main(string [] args)
{
}
}
}
$ c $ Main
方法可以作为一个固定的方法来使用。
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)
{
}
}
}
解决方案
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.
这篇关于为什么我不能在C#应用程序中使用泛型类型的入口点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文