Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resolving an ambiguous reference

Tags:

c#

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?

For example,

using tool.2dChartLib; using tool.3dChartLib; 

BorderStyle is a member of both of these

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

like image 440
Sayse Avatar asked Jan 03 '13 14:01

Sayse


People also ask

What is ambiguous reference?

An ambiguous reference is the situation in which a sentence contains a pronoun that could refer to either of two nouns in the same sentence or (using our new vocabulary word) where we have a pronoun but we aren't sure what its antecedent is.

What is ambiguous error in C#?

ambiguity error is that you named field and property tha same name "colour". change the property definition f.e. public string Colour { get { return colour;} set { colour = value;} }


1 Answers

If the types with the same name exist in both namespaces, you have a couple of options:

1) If the number of types is small, create an alias for that type:

using BorderStyle3d = tool.3dChartLib.BorderStyle; 

2) If the number of types is large, you can create an alias for the namespace:

using t3d = tool.3dChartLib; 

Then in your code...

t3d.BorderStyle 
like image 78
Adam Robinson Avatar answered Sep 30 '22 14:09

Adam Robinson