Wednesday, 15 April 2015

c# - How get the max length value of an array? -



c# - How get the max length value of an array? -

i'm amateur in c#; i'm trying convert function of vb.net c#...

<editorbrowsable(editorbrowsablestate.always)> _ <extension()> _ public function mc_getmaxlengthvalue(byval values() string) string mc_getmaxlengthvalue = "" if values.count > 0 mc_getmaxlengthvalue = values.orderbydescending(function(value) value.length).first end function

i can't figure out how convert orderbydescending(function(value) value.length).

in terms of functionality, want max length in array. ex: {"123456", "123", "1234"}. want "123456" (the longest string).

values.orderbydescending(o => o.length).first() //max value list.max(o => o.length) //max length

c# arrays vb.net linq

No comments:

Post a Comment