本文介绍了使用语句泛型:在使用的ISet<> = System.Collections.Generic.ISet<>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我使用两种不同的泛型集合的命名空间( System.Collections.Generic Iesi.Collections.Generic ),我有冲突。在项目的其他部分,我同时使用NUnit的和MSTest的框架,但有资格当我称之为断言我想通过

Since I am using two different generic collection namespaces (System.Collections.Generic and Iesi.Collections.Generic), I have conflicts. In other parts of the project, I am using both the nunit and mstest framework, but qualify that when I call Assert I want to use the nunit version by

using Assert = NUnit.Framework.Assert;

伟大的工程,但我想这样做同样的事情泛型类型。然而,以下行不工作

Which works great, but I want to do the same thing with generic types. However, the following lines do not work

using ISet = System.Collections.Generic.ISet;
using ISet<> = System.Collections.Generic.ISet<>;

有谁知道如何告诉.NET如何使用using语句与泛型?

Does anyone know how to tell .net how to use the using statement with generics?

推荐答案

我觉得你最好走样的命名空间本身,而不是通用的类型(我不认为是可能的)。

I think you're better off aliasing the namespaces themselves as opposed to the generic types (which I don't think is possible).

因此​​,例如:

using S = System.Collections.Generic;
using I = Iesi.Collections.Generic;

对于BCL然后的ISet&LT; INT&GT; ,例如:

S.ISet<int> integers = new S.HashSet<int>();

这篇关于使用语句泛型:在使用的ISet&LT;&GT; = System.Collections.Generic.ISet&LT;&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 00:32