本文介绍了任何可能的使用此功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以定义两个具有相同名称的类,但在一个程序集中具有不同的通用

参数。如下:


class Gen< T>

{

}


Gen Gen< T1,T2>

{

}


任何可能的用途?

解决方案





的泛型v2。


-

Jon Skeet - < sk *** @ pobox.com>


如果回复群组,请不要给我发邮件





可能 - 我可以想象一些像数组列表的东西

但是有多个尺寸,每个尺寸都是不同的

类型。例如,你可以这样做:


myList [10," hello"] =" there";


使用直接泛型ArrayList你可以很容易地找到


myList [10] [" hello"] =" there";


我怀疑,但是在某些情况下,第一种语法可能会更好。


可能不是*非常有用,但只是想知道如何使用它。


-

Jon Skeet - < sk *** @ pobox.com>


如果回复小组,请不要给我发邮件

you can define two class with same name but having different generic
parameters in one assembly. As below:

class Gen<T>
{
}

class Gen<T1,T2>
{
}

any possible use of it?

解决方案





I think Justin was actually talking about the generics which will be
available in C# v2.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too




Possibly - I could imagine something which would be like an array-list
but with multiple "dimensions", each of which would be a different
type. For instance, you could do:

myList[10,"hello"] = "there";

With straight generics on ArrayList you could easily get to

myList[10]["hello"] = "there";

I suspect, but the first syntax might be better in some circumstances.

Probably not *really* useful, but just an idea of how it might be used.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于任何可能的使用此功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 23:44
查看更多