C
C#•3mo 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•3mo ago
context?
Itskillerluc
ItskillerlucOP•3mo ago
LINQ .Min
Pobiega
Pobiega•3mo ago
oh, you mean Method group syntax
Itskillerluc
ItskillerlucOP•3mo ago
names.Min<string>(x => x.Length()) like cant i do the lambda shorter
Pobiega
Pobiega•3mo ago
since Length is a property, not a method, thats not available
LPeter1997
LPeter1997•3mo ago
Count :trollface:
Itskillerluc
ItskillerlucOP•3mo ago
i thought it was a method how do i even see if its a method or a property
Pobiega
Pobiega•3mo ago
by using your eyes
Itskillerluc
ItskillerlucOP•3mo ago
i hate the c# naming conventions
Pobiega
Pobiega•3mo ago
🙂
Itskillerluc
ItskillerlucOP•3mo ago
i dont see the source tho
Pobiega
Pobiega•3mo ago
No description
Itskillerluc
ItskillerlucOP•3mo ago
it looks exactly the same as a method
LPeter1997
LPeter1997•3mo ago
No description
Itskillerluc
ItskillerlucOP•3mo ago
ye i dont see that so there is no way to write this shorter then?
Pobiega
Pobiega•3mo ago
no also.. why? x => x isnt that long
Itskillerluc
ItskillerlucOP•3mo ago
its ugly
Pobiega
Pobiega•3mo ago
its important
sibber
sibber•3mo ago
you dont have intellisense?
LPeter1997
LPeter1997•3mo 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
ItskillerlucOP•3mo ago
idk my rider seems to not work rn
Pobiega
Pobiega•3mo ago
then fix your rider coding without intellisense is just making your life harder for no reason
LPeter1997
LPeter1997•3mo ago
No description
LPeter1997
LPeter1997•3mo ago
Idk... I'd just write the latter
Itskillerluc
ItskillerlucOP•3mo 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•3mo ago
embrace the lambda. learn to love it
LPeter1997
LPeter1997•3mo 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•3mo ago
invalidate caches and restart, that tends to fix the editor being drunk for me
Want results from more Discord servers?
Add your server