The call is ambiguous between the following methods or properties (bug??)

12 浏览
0 Comments

The call is ambiguous between the following methods or properties (bug??)

  1. 创建一个新的ASP.NET MVC Web应用程序
  2. 创建一个ASP.NET App_Code文件夹
  3. 在新文件夹中创建一个带有扩展方法的类。例如:

    static public class BugMVCExtension
    {
        public static int ToInt(this string str)
        {
            return Convert.ToInt32(str);
        }
    }
    

  4. 选择一个视图并尝试使用这个新的扩展方法

您将会得到以下异常:

CS0121: 调用在以下方法或属性之间存在歧义:
'*MvcApplication1.App_code.BugMVCExtentions.ToInt(string)*' 和
'*MvcApplication1.App_code.BugMVCExtentions.ToInt(string)*'

这里有人对此有更多的信息吗?

在ASP.NET MVC (?) Web应用程序中创建一个App_code文件夹是否有问题?

0