Re: What is a property?
- From: "Christof Nordiek" <cn@xxxxxxxxx>
- Date: Mon, 4 Jul 2005 15:00:03 +0200
Hi Peter,
> It is also possible via getter and setter methods. What exact benefit does
> a "property" give us over getter and setter methods?
Simply look at this Example and decide yourselve, wich is more readable:
oldText = control.get_Text();
control.get_Text(newText);
vs.
oldText = control.Text;
constrol.Text = newText;
Christof
"Peter Kirk" <pk@xxxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:u1GkVPJgFHA.3448@xxxxxxxxxxxxxxxxxxxxxxx
> "Prakash Prabhu K" <PrakashPrabhuK@xxxxxxxxxxxxxxxxxxxxxxxxx> skrev i en
> meddelelse news:390C9AB7-86F2-4D6D-9E00-21B1AEDEDFE2@xxxxxxxxxxxxxxxx
>> Hi Peter,
>>
>> we can tell properties are smart fields (Class members) in C#. Public
>> fields
>> in the class would give complete access to field from other classes. So
>> it is
>> not possible to give read-only or write only access to public fields.
>> This is
>> possible through properties.
>>
>> Properties can give read only, write only or read right access to
>> fields.
>> This also allow us to add extra business logic to fields.
>
> It is also possible via getter and setter methods. What exact benefit does
> a "property" give us over getter and setter methods?
>
>
>
.
- Follow-Ups:
- Re: What is a property?
- From: Steve Walker
- Re: What is a property?
- References:
- What is a property?
- From: Peter Kirk
- RE: What is a property?
- From: Prakash Prabhu K
- Re: What is a property?
- From: Peter Kirk
- What is a property?
- Prev by Date: c# and Excel range coordinates
- Next by Date: Re: What is a property?
- Previous by thread: Re: What is a property?
- Next by thread: Re: What is a property?
- Index(es):
Relevant Pages
|