如何从一个值中选择两个值

Jac*_*nev 2 c# linq

我想返回一个字符串集合,其中每个第二个记录都是"0",类似于:

        foreach (Customer c in customers)
        {
            yield return c.Name;
            yield return "0";
        }
Run Code Online (Sandbox Code Playgroud)

我已开始:

customers.Select(c => new
                                      {
                                          c.Name,
                                          Second = "0"
                                      }).???
Run Code Online (Sandbox Code Playgroud)

dan*_*dan 7

你需要SelectMany:

var resultList = 
    customers.SelectMany(c => new[] {c.Name, "0"});
Run Code Online (Sandbox Code Playgroud)

这将获取您的源列表,并为每个项目后面插入一个"0".