Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Property vs. Method
Message
De
15/10/2008 14:20:28
Mike Yearwood
Toronto, Ontario, Canada
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01354904
Message ID:
01355205
Vues:
28
>>>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
Fil
Voir

Click here to load this message in the networking platform