Reputation: 1104
I have an extension method on my project that has been working fine:
public static class Extensions
{
public static bool IsBetween<T>(this T value, T low, T high)
where T : IComparable<T>
{
return value.CompareTo(low) >= 0 && value.CompareTo(high) <= 0;
}
}
Now when I try to build my project I get this error:
Error 1699 The call is ambiguous between the following methods or properties: 'BillingFormsApplication.Extensions.IsBetween(double, double, double)' and 'BillingFormsApplication.Extensions.IsBetween(double, double, double)'
There is only one IsBetween
method in the Extensions
file... AND only one IsBetween
method in the entire solution.
I tried to clean and rebuild the solution. Still getting the error.
I could remove the extension and keep going, but it has been quite handy in the past.
Added for Frederic:
if (percentCash.IsBetween(0, 99))
{
I wonder if I cast those numbers to Double if that will fix it. I'll try that in a minute. Like:
if (percentCash.IsBetween((double)0, (double)99))
Upvotes: 3
Views: 2009
Reputation: 48686
More than likely, you are referencing a DLL that has this same extension method defined or you got this defined somewhere else in your code. Try doing a find in files search for IsBetween
and see if it comes up. If not, look at the DLLs you have referenced and see if this extension doesn't exist in one of those.
Upvotes: 2