C
C#•2mo ago
Itskillerluc

shorter way of writing x => x.Length()

I thought you could just put string.Length? but you apparently cant? is there no way to write it shorter?
28 Replies
Pobiega
Pobiega•2mo ago
context?
Itskillerluc
Itskillerluc•2mo ago
LINQ .Min
Pobiega
Pobiega•2mo ago
oh, you mean Method group syntax
Itskillerluc
Itskillerluc•2mo ago
names.Min<string>(x => x.Length()) like cant i do the lambda shorter
Pobiega
Pobiega•2mo ago
since Length is a property, not a method, thats not available
LPeter1997
LPeter1997•2mo ago
Count :trollface:
Itskillerluc
Itskillerluc•2mo ago
i thought it was a method how do i even see if its a method or a property
Pobiega
Pobiega•2mo ago
by using your eyes
Itskillerluc
Itskillerluc•2mo ago
i hate the c# naming conventions
Pobiega
Pobiega•2mo ago
🙂
Itskillerluc
Itskillerluc•2mo ago
i dont see the source tho
Pobiega
Pobiega•2mo ago
No description
Itskillerluc
Itskillerluc•2mo ago
it looks exactly the same as a method
LPeter1997
LPeter1997•2mo ago
No description
Itskillerluc
Itskillerluc•2mo ago
ye i dont see that so there is no way to write this shorter then?
Pobiega
Pobiega•2mo ago
no also.. why? x => x isnt that long
Itskillerluc
Itskillerluc•2mo ago
its ugly
Pobiega
Pobiega•2mo ago
its important
sibber
sibber•2mo ago
you dont have intellisense?
LPeter1997
LPeter1997•2mo ago
You can technically write Enumerable.Count, does have some overhead but should not actually iterate the entire str. Also I'd never do that...
Itskillerluc
Itskillerluc•2mo ago
idk my rider seems to not work rn
Pobiega
Pobiega•2mo ago
then fix your rider coding without intellisense is just making your life harder for no reason
LPeter1997
LPeter1997•2mo ago
No description
LPeter1997
LPeter1997•2mo ago
Idk... I'd just write the latter
Itskillerluc
Itskillerluc•2mo ago
ye i know i will fix it well its fine i jsut thought there would be the shorter way of writing it
Pobiega
Pobiega•2mo ago
embrace the lambda. learn to love it
LPeter1997
LPeter1997•2mo ago
You can also write your own method if you write it that many times... Like
static int Length(string s) => s.Length;
static int Length(string s) => s.Length;
But generally only if this is local to a class of yours or something, definitely do not put this in some shared context, that's confusing and Pythonic af
Jimmacle
Jimmacle•2mo ago
invalidate caches and restart, that tends to fix the editor being drunk for me
Want results from more Discord servers?
Add your server