by spanhandler · 6y ago · 0 comments
.length, .size, .len, .count, then all those again but as functions taking an array argument, then again but as method calls, are not. And that’s not all the possibilities!
Seriously I bounce between languages enough that I have to look this shit up every time if autocomplete doesn’t help me out, and even that might take a couple tries.
It's a good thing that Intellisense is top notch !
I guess you could make IEnumerable's Count() into a property and enjoy the same syntax but I am not sure it's a good idea, because Count() needs to enumerate and is therefore O(n), and property syntax may coax you into writing with the expectation that it is O(1).
Then suddenly (it's been years since I did c#) I recall that Count() is added to the interface as an extension method with the "this" keyword. Is it possible to have an extension property? I do not think so but again it's been a while.