When to use a property vs a method?

.net, c#, oop

Solution

The general standard is about side effects. If by calling a member to get a value you only get that value it's a property. If there are side effects, it should probably be a method.

To put it another way: properties even though they aren't fields should behave very much like fields. This means not causing side effects, not taking too long to execute and not throwing exceptions.

Problem

Possible Duplicate: Properties vs Methods Is there any rule or general best practice as to when to use a property vs a method? Technically any parameterless method can be made in a property and any property can be made a method, but sometimes when to decide when to use one of the other can be blurred. I was hoping to get some rules you guys kept in mind when deciding between the two.

Original source

Related problems