0
我創建十進制AsCurrency擴展方法(此十進制量)小數擴展方法曖昧
當我建立我會得到錯誤
呼叫是下列方法或屬性之間曖昧: 'CurrencyHelper.AsCurrency(decimal)'和 'CurrencyHelper.AsCurrency(decimal)'
whate hell?如果我清除解決方案,它會再次構建。下次它會再次失敗。
是十進制問題還是有我的解決方案出了問題?
有沒有人遇到同樣的問題?
編輯
擴展是在一個集會。 CurrencyHelper只有一個定義。
下面的代碼:
public static class CurrencyHelper
{
public static string AsCurrency(this decimal amount)
{
return ((decimal?) nr).AsCurrency();
}
public static string AsCurrency(this decimal? amount)
{
var cultureInfo = ...
return (nr ?? 0).ToString("c2", cultureInfo);
}
}
的想法是格式化與所需的CultureInfo十進制值,如果量爲null,0仍提供
您是否有'CurrencyHelper'在兩個不同的程序集中定義?也許你已經將'.cs'文件分享到了兩個?這將導致衝突... –
郵政編碼請。 – BlackICE
你可以有一個項目的引用(正確)到一個項目的擴展程序集,並且該同一程序集的dll-reference(錯誤)?然後你可能會遇到VS版本衝突,VS會看到同一個DLL的兩個版本。雖然我會期待一個「版本衝突」錯誤... –