解决不明确的引用 [英] Resolving an ambiguous reference
问题描述
我试图创造一个经理级与我的图表工具来使用,问题是我用的工具,使用相同的名字是导致不明确的引用既3D和2D图表,当我尝试添加2D库..任何想法如何以最佳方式解决这个问题?
I'm trying to create a manager class to use with my charting tool, the problem is the tool I use, uses the same names for both a 3d and 2d charts which is resulting in ambiguous reference when I try to add the 2d library.. any ideas how best to resolve this?
例如,
using tool.2dChartLib;
using tool.3dChartLib;
边框是这两种的成员
BorderStyle is a member of both of these
我试过铸造,我使用边框的区域。我想它可以工作,如果我只是引用工具
但随后这将意味着我有上百个 tool.class
的行,而不是类
I've tried casting the areas where I use BorderStyle. I suppose it could work if i just reference tool
but then that would mean I'd have hundreds of tool.class
lines instead of class
推荐答案
如果在这两个命名空间中存在具有相同名称的类型,你有两个选择:
If the types with the same name exist in both namespaces, you have a couple of options:
1)如果类型的数目小,该类型创建别名:
1) If the number of types is small, create an alias for that type:
using BorderStyle3d = tool.3dChartLib.BorderStyle;
2)如类型的数目大,可以为名称空间创建别名:
2) If the number of types is large, you can create an alias for the namespace:
using t3d = tool.3dChartLib;
然后在你的code ...
Then in your code...
t3d.BorderStyle
这篇关于解决不明确的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!