Error: member names cannot be the same at their enclosing type

123 views Asked by At

I was using ASP.NET4.5 and visual studio 2013 to create a sample application Wingtip Toys. But when trying to display data item and details It showing error in the last line of code bellow which is- protected global::System.Web.UI.WebControls.ListView ProductList;

ProductList: member names cannot be the same at their enclosing type.

namespace WingtipToys
{
    public partial class ProductList 
    {        
        /// <summary>
        /// ProductList control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.ListView ProductList;
    }
}
1

There are 1 answers

1
Martin Noreke On

The class ProductList cannot contain a field, property, or method named ProductList as well. Try using the following code instead:

public partial class ProductList
{
    /// <summary>
    /// ProductList control.
    /// </summary>
    /// <remarks>
    /// Auto-generated field.
    /// To modify move field declaration from designer file to code-behind file.
    /// </remarks>
    protected global::System.Web.UI.WebControls.ListView Products;
}

Likewise, a namespace cannot contain a class with the same name as the namespace.