I have a class with a collection of methods in, and I was wondering if there is any performance bonus of using methods over properties?
Some of the methods are fairly complex, but basically return an IEnumerable collection of objects, while others are a simple return values.Where(x => x.property == "comparison")
Linq query.
Examples
Method:
public IEnumerable<PenDataRow> ActivePens() => Pens.Where(x => x.Status == "Active");
Property:
public IEnumerable<PenDataRow> ActivePens => Pens.Where(x => x.Status == "Active");
Would it be better to mark them as properties or methods?
Properties are implemented as methods under the hood, so there is absolutely no performance difference. The guidelines for choosing between a property and a method are semantic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With