Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq ForEach in string interpolation [closed]

Tags:

c#

linq

In order to make my code superclear, I'm trying to do something like that:

var result = $@"...
<div class='modal-body'>
    {content}
</div>
{(haveButtons ? "" : "<div class='modal-footer'>")}
{modalButtons.ForEach(m => "INSERT SOME HTML")}
{(haveButtons ? "" : "</div>")}
..."

But, of course, that doesn't compile because in the lambda I need to put some code and not just a magic return. Is there any way to do that?

like image 213
Ragz Avatar asked Jan 29 '23 20:01

Ragz


1 Answers

{string.Join("", modalButtons.Select(m => "INSERT SOME HTML"))}
like image 119
RVid Avatar answered Feb 06 '23 10:02

RVid