C# 0 The Complete Reference



Download 4,07 Mb.
Pdf ko'rish
bet199/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   195   196   197   198   199   200   201   202   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

Width

 and 


Height

 associated with the invoking object will be 

multiplied together and the result returned. However, the same statement can also be 

written like this:

return this.Width * this.Height;

Here, 


this

 refers to the object on which 



Area( )

 was called. Thus, 



this.Width

 refers to that 

object’s copy of 

Width

, and 


this.Height

 refers to that object’s copy of 



Height

. For example, 

if

Area( )

 had been invoked on an object called 



x

, then 


this

 in the preceding statement 

would have been referring to 

x

. Writing the statement without using 



this

 is really just 

shorthand.

It is also possible to use 



this

 inside a constructor. In this case



this

 refers to the object 

that is being constructed. For example, inside 

Rect( )

, the statements

Width = w;

Height = h;

can be written like this:

this.Width = w;

this.Height = h;

Of course, there is no benefit in doing so in this case.

For the sake of illustration, here is the entire 

Rect

 class written using the 



this

 reference:

using System;

class Rect {

  public int Width;

  public int Height;

  public Rect(int w, int h) {

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   195   196   197   198   199   200   201   202   ...   1096




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish