如何将列表中的行文本连接到 .Net Core wep 中的成功文本消息 api

How to concat rows text from a list into a success text msg in .Net Core wep api

将列表中的行文本连接到 .Net Core wep 中的成功文本消息 api

与WebAPI本身无关。这更像是一个框架问题。使用string.Join(定界符,可枚举).

但是,这里有一个例子:

[Route("api/[controller]")]
public class DemoController : Controller
{
    [HttpGet]
    public IActionResult Get()
    {
        var listOfMessages = new[] {"these", "should", "be", "combined"};
        var result = string.Join(' ', listOfMessages);
        return Ok(result);
    }
}

结果如下所示:

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Date: Tue, 22 May 2018 10:59:38 GMT
Content-Length: 24

these should be combined