C#语法问题 this的用法

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的具体用法
其他人气:442 ℃时间:2020-01-27 16:51:03
优质解答
你这里声明了一个类Users:public class Users那么,在类中的代码里使用this,指代的就是 Users 这个类.比如说this._userid,指的就是Users类下面的成员int _userid(你已经在代码里声明过了成员int _userid:private i...
我来回答
类似推荐
请使用1024x768 IE6.0或更高版本浏览器浏览本站点,以保证最佳阅读效果。本页提供作业小助手,一起搜作业以及作业好帮手最新版!
版权所有 CopyRight © 2012-2024 作业小助手 All Rights Reserved. 手机版