Mike Yearwood
Toronto, Ontario, Canada
Versions des environnements
Network:
Windows 2008 Server
>>>The age old questions. Should I use a property or a method? Is one faster than the other?
>>
>>From Tracy's link:
>>
>>In general, methods represent actions and properties represent data.
>>
>>Rarely stray from the generalization. That way, in general a property will be faster than a method as there is no cumbersome execution likely to occur.
>
>What do methods act on? Nothing?
Well, obviously parameters. Surely you know a method need not read/write any properties at all. However, imagine a property with a huge set of code fired from a get method and other properties also firing their own set(s) of code. All you're trying to do is get the value and it takes a few seconds? I'd rather rely on accessing a property taking minimal execution time and minimal debugging time too.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement