4

I have a method named IsDone. This method does some checks and returns true or false.

Is there any benefit in using a Property without a setter instead?

John Demetriou
  • 672
  • 1
  • 10
  • 18

1 Answers1

4

If you don't modify the internal state and the checks does not have a lot of overhead a property is more appropriate. This article from MSDN provides some good guidelines to choose method vs property https://msdn.microsoft.com/en-us/library/ms229054(v=vs.100).aspx

Chamindu
  • 328
  • 1
  • 6
  • What about this new way in C# 6? the => ? dont know whats called that's why I did not put it in the question – John Demetriou Jul 08 '16 at 07:51
  • 1
    @JohnDemetriou If you mean creating a function/property body with the `=>` syntactic sugar, that's called Expression bodied function (or property). I believe in C# the fat-arrow (`=>`) symbol itself is mostly associated with lambda expressions. – Andy Jul 08 '16 at 07:55
  • I know about Lambdas. Its just the latest resharper keeps suggesting get only properties to use that. But I guess yeah, it a lambda expression for the property. Cool Thanks – John Demetriou Jul 08 '16 at 08:09