C#语法问题 this的用法
public class Users
{
private int _userid;
private string _username;
private string _userpwd;
public int UserId
{
get { return this._userid; }
set { this._userid = value; }
}
public string UserName
{
get { return this._username; }
set { this._username = value; }
}
public string UserPwd
{
get { return this._userpwd; }
set { this._userpwd = value; }
}
public Users()
{
//
// TODO:在此处添加构造函数逻辑
//
}
public Users(int UserId,string UserName,string UserPwd)
{
this._userid = UserId;
this._username = UserName;
this._userpwd = UserPwd;
}
public Users(SqlDataReader Dr)
{
this._userid = Convert.ToInt32(Dr["UserId"]);
this._username = Dr["UserName"].ToString();
this._userpwd = Dr["UserPwd"].ToString();
}
上面代码中用了很多this 谁能讲一下啊是什么用意 在什么情况下一定要加上this
不要复制给我帮助中公式般回答 通俗的讲一下this的具体用法
人气:347 ℃ 时间:2020-01-27 16:51:03
解答
你这里声明了一个类Users:public class Users那么,在类中的代码里使用this,指代的就是 Users 这个类.比如说this._userid,指的就是Users类下面的成员int _userid(你已经在代码里声明过了成员int _userid:private i...
推荐
猜你喜欢
- 长方体棱长和为216厘米,它的长、宽、高之比为4比3比2,长方体的表面积是多少平凡厘米
- 用英语翻译:在一个岛上
- 一个初三动词时态填空.很简单的说
- 一直a>b>c>d,则(1/(a-b)+1/(b-c)+1/(c-d))*(a-d)的最小值
- (1)画圆O以及互相垂直的两条直径AB,CD;以点A为圆心,AO为半径画弧,交圆O于点E,F(点E在劣弧AC上);连接AE,AD,EF,EC,OE,OF;
- 三元一次函数在空间直角坐标系中怎么画?
- 尤其初2的数学和英语基础不是很扎实
- 一辆初速度为18km/h的汽车,以0.5m/s2加速度做匀加速直线运动,加速到10s时汽车的速度是多大?