c# - how can I convert this foreach loop to linq? -


i'm new linq. want convert these lines of code linq lambda expression, if makes sense how can achieve?

foreach (var type in essay.text) {      string text =           $"{"here result"}\n{method(type)}";      if (text.length <= 20 && !string.isnullorempty(method(type)))      {           essay.total += text;      } } 

with of resharper:

essay.total = string.concat(             essay.text.select(type => new {type, text = $"{"here result"}\n{method(type)}"})                 .where(@t => @t.text.length <= 20 && !string.isnullorempty(method(@t.type)))                 .select(@t => @t.text)             ); 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -