方法:public void abcd(int x,int y)
{
}
属性用public 声明

解决方案 »

  1.   

    方法:
    public void yourMethod(string s)
    {
    }
    属性
    string connstr="";
    public string ConnectionString
    {
    get
    {
    return connstr;
    }
    set
    {
    connstr=value;
    }
    }
      

  2.   

    public class CustomClass
    {
    //私有变量
    private string priStr;
    //可读写属性
    //1、形如 public [类型] [名称]
    public string Property1//2、使用get set
    public string Property2
    {
       get
       {
          return priStr;
       }
       set
       {
          priStr=value;
       }
    }
    //只读属性
    public string PropertyReadOnly
    {
       get
       {
          return priStr;
       }
    }//只写属性
    public string PropertyWriteOnly
    {
       set
       {
          priStr=value;
       }
    }
    //方法:形如 public [返回值] 方法名([参数1],[参数2],……)
    //3、无返回值方法
    public void MyMethod(int index)
    {
       index++;
    }
    //返回int类型
    public int MyAdd(int index)
    {
       return index++;
    }
    }
      

  3.   

    方法:
    public void yourMethod(string s)
    {
    //do the operation
    }
    string strtemp;
    public string temp_variable
    {
    get
    {
    return strtemp;
    }
    set
    {
    strtemp=value;
    }
    }