Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Public Get and private Set?
Message
 
À
27/07/2005 11:06:08
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01035993
Message ID:
01036303
Vues:
8
Bonnie,
That is true. Meditate on this I will. (I know it would be bad to use strong words like never and always <s>)

Einar
>Einar,
>
>Well, ok, I'll agree with you in that situation ... but it seems wasteful to try and give every single private variable a property when most of the time you are not going to need this sort of checking in the set of a property.
>
>Just my 2 cents, I may be wrong. <g>
>
>~~Bonnie
>
>
>
>
>>Bonnie,
>>I am not sure I really have a good answer for this, but here we go. Using a property to update all private members just seems more "secure" to me. Let's say I have a private byte myByte member, but the value can only range from 0x32 to 0xCD, I would put the code to check the value in the set method.
>>
>>Einar
>>
>>>Einar,
>>>
>>>I'm curious as to why you don't want to access private members directly?
>>>
>>>~~Bonnie
>>>
>>>
>>>>Bonnie,
>>>>Thanks for your reply. That is what I ended up doing, but I would have prefered to only have one property name where I could only set it privately and get it publicly.
>>>>The more I thought about this I figured it would be a nightmare for the compiler. I am trying to never access the private members directly but always use a property, but sometimes I don't want to expose the set publicly (wow never and always in the same sentence lol <s>).
>>>>
>>>>Ohh well better to ask than to wonder.
>>>>
>>>>Again thanks.
>>>>
>>>>Einar
>>>>
>>>>>Nope. Victor's correct. But, keep in mind that you don't *have* to have a set, so you could leave it out of the public property, which would essentially make that property read-only.
>>>>>
>>>>>~~Bonnie
>>>>>
>>>>>
>>>>>
>>>>>>I am pretty sure I know the answer to this one myself already, but I would still like to pose the question.
>>>>>>
>>>>>>Can I make the Get method of a property public and the Set method of the same property private?
>>>>>>
>>>>>>Thanks,
>>>>>>Einar
Semper ubi sub ubi.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform