无法对属性或索引器“bll.perinfor.id”赋值 -- 它是只读的
protected void Page_Load(object sender, EventArgs e)
{
int sid =Convert.ToInt32(Request.QueryString["id"]);
Response.Write(sid);
perinfor pi = new perinfor();
pi.id = sid; Person p = new Person();
pi=p.selectp(pi);
this.Label1.Text = pi.username;
this.Label2.Text= pi.userpwd;
}
public class perinfor
{
private int ido;
private string usernameo;
private string userpwdo;
public perinfor()
{ }
public perinfor(int id, string username, string userpwd)
{
this.ido = id;
this.usernameo = username;
this.userpwdo = userpwd;
}
public int id
{
get { return ido; }
}
public string username
{
get { return usernameo; }
}
public string userpwd
{
get { return userpwdo; }
}
}
为什么说错误 1 无法对属性或索引器“bll.perinfor.id”赋值 -- 它是只读的 d:\neT源代码\guestbook\user.aspx.cs 20 9 d:\neT源代码\guestbook\?》???
------解决方案--------------------
public int id
{
get { return ido; }
}
因为它只有get,没有set,所以只能取得他的值,不能为他赋值,要想复制的话,必须加set