Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Method vs. Property
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01058026
Message ID:
01058164
Vues:
15
>>I have been discussing pros and cons with myself now for about 15 minutes, whether I should use a method or a property. Now I am seeking some input form somebody else other than myself LOL
>>
>>I have a usercontrol with several widgets on it. In addition to having properties to get/set each of the widgets individualy I would like to add a method or a property to set/get all the widgets at the same time, by passing/returning a byte array. I just can't make up my mind if I should use a method to do this or a property.
>>
>>
>>public void MethodName (byte[] paraBA)
>>{
>>  //code
>>}
>>
>>public byte[] MethodName ()
>>{
>>  //code
>>}
>>
>>or
>>
>>public byte[] PropertyName
>>{
>>  get
>>  {
>>    //code
>>  }
>>  set
>>  {
>>    //code
>>  }
>>}
>>
>>
>>I guess at the end of the day it doesn't really matter, but I would like to know your opinion.
>>
>>
>>Thanks,
>
>Einar,
>
>Get/Set indicate that these are fields not properties. Rather than a method use the Get and Set events to store the values into private properties.

Einar,

Are you going to store the state of your new property? If so, are you going to then monitor all the properties you set to make certain they stay that way? It would seem you'd want a method because you probably don't want to store the state of your action separately.

Does that make sense?

Just a though,
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform