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:在此處添加構(gòu)造函數(shù)邏輯
//
}
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
不要復(fù)制給我?guī)椭泄桨慊卮?通俗的講一下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:在此處添加構(gòu)造函數(shù)邏輯
//
}
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
不要復(fù)制給我?guī)椭泄桨慊卮?通俗的講一下this的具體用法
其他人氣:479 ℃時間:2020-01-27 16:51:03
優(yōu)質(zhì)解答
你這里聲明了一個類Users:public class Users那么,在類中的代碼里使用this,指代的就是 Users 這個類.比如說this._userid,指的就是Users類下面的成員int _userid(你已經(jīng)在代碼里聲明過了成員int _userid:private i...
我來回答
類似推薦
- Is和 This在語法和用法上有什么區(qū)別
- java中this的作用及用法?在什么情況下需要用this
- this morning是用什么句式?
- 英語句子中l(wèi)ong的語法用法?A have made this long obsolete
- 初中英語語法,問一個關(guān)于this和that的用法
- 英語翻譯
- 將粉筆頭輕放在以2m/s運動的傳送帶上,傳送帶留下一條長度為4米的劃線.請問,為什么劃線的長度等于傳送帶的位移減去物體的位移?請詳解,
- <<湯姆索亞歷險記>>以什么為線索,鞭撻了什么?
- 桂花雨主要內(nèi)容?30字以上
- 誰能幫我想個詞來形容這個人
- (找等量關(guān)系列方程)
- 等比數(shù)列{an}中,a1+a2=8,a3-a1=16,則a3等于( ?。?A.20 B.18 C.10 D.8
猜你喜歡
- 1自天然藥物提取液中識別生物堿是否存在的主要反應(yīng)及其試劑有哪些
- 2已知函數(shù)f ( x )等于(cos x)的四次方減去2sin xcos x減去(sin x)的四次方.1)求f ( x ) 的最小正周期;...
- 3在9 8 7 6 5 4 3 2 1=20添上加減乘除使等式成立
- 4用“攛掇”“絮叨”“怠慢”造句
- 5△ABC中,B>90° a=2x-5 b=x+1 c=4 求 x的取值范圍.
- 6Experience more than sufficiently teaches that men govern nothing with more difficult than their tongues.問govern sth wit
- 7氧化銅與稀硫酸反應(yīng)的化學(xué)方程式
- 8為什么高中化學(xué)先學(xué)的離子反應(yīng)再學(xué)氧化還原反應(yīng) 離子反應(yīng)里面有好多寫的時候要用到氧化還原的知識的啊
- 9已知:關(guān)于x的方程kx^2-(4k+1)x+3k+3=0
- 10語文作文:如何審題?如何理解話題?
- 11先生的讀音,生是讀一聲還是輕聲
- 12額定電壓220V、容量100L、電阻24.2Ω的電熱水器,它的電功率是多少?