在C#中:是否可以使用泛型参数类的类型作为方法的返回类型或定义成员?类似于C++模板中的C#泛型类型演绎?
C++示例:
class AgrumentClass
{
typedef int type;
public:
static type GetSomething() { return 0; }
};
template< class T >
class GenericClass
{
typedef typename T::type type;
public:
static type GetSomething() { return T::GetSomething(); }
};
int main()
{
int value = GenericClass<AgrumentClass>::GetSomething();
return value;
}
我投票结束这个问题作为题外话,因为它不是代码转换工具! – mybirthname
是的,这是可能的,你可以学习C#泛型,你可以在任何地方使用它们https://msdn.microsoft.com/en-us/library/512aeb7t.aspx –
@mybirthname他没有要求代码转换工具。他问C#中是否有并行功能,并且包含一个C++示例来展示他所指的概念。 –