I have seen from some book where this kind of code has been given.
Type[] types = typeof(TypeA, TypeB);
whether it is some new feature that has y et to be supported now, or is it somehting that is typo from the original books...
Let's give a try, and below is the test result.
class TypeA
{ }
class TypeB
{
}
class Program
{
static void Main(string[] args)
{
Type[] types = typeof(TypeA, TypeB);
if (types.Length > 0)
{
Console.WriteLine("syntax type(ypeA, TypeB) is OK");
}
else
{
Console.WriteLine("syntax type(TypeA, TypeB) is not OK");
}
}
}
while, the code stop to compile in the first place. so the myth-buster, typeof can accept more than one type as arguments - proven false.
本文详细解析了C#中通过typeof方法创建类型别名的语法和实现过程,通过实例展示了如何正确地使用类型别名,并揭示了常见错误及解决策略。
5247

被折叠的 条评论
为什么被折叠?



