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