修饰符public对此项无效

Pra*_*eep 5 c#

我收到了错误

修饰符public对此项无效

这是我的代码,请帮帮我.

    using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    public partial class First : System.Web.UI.Page,test 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = test1("Hi", 1).ToString();
        }

    }
    public class Base
    {
        public int test1(int x)
        {
            return x;
        }
        public string test1(string x)
        {
            return x;
        }
        public string test1(string x, int y)
        {
            return x + y;
        }
    }
    public interface test
    {
        public int test1(int x);
        public string test1(string x);
        public string test1(string x, int y);
    }
Run Code Online (Sandbox Code Playgroud)

谢谢Pradeep

Dar*_*rov 19

您的接口声明应如下所示:

public interface test
{
    int test1(int x);
    string test1(string x);
    string test1(string x, int y);
}
Run Code Online (Sandbox Code Playgroud)

访问修饰符在接口声明上无效:

接口由方法,属性,事件,索引器或这四种成员类型的任意组合组成.接口不能包含常量,字段,运算符,实例构造函数,析构函数或类型.它不能包含静态成员.接口成员自动公开,并且不能包含任何访问修饰符.