0

给定以下两个IEnumerable(Of String)未知长度,我怎样才能产生非明显联合?

Dim theseStrings As IEnumerable(Of String) =
    {"true", "true", "true", "true", "true"}
Dim thoseStrings As Ienumerable(Of String) =
    {"false", "true", "false", "false"}

结果应如下所示:

{"false", "true", "false", "false", "true"}

意思是

  • 的必须等于Count_result CounttheseStrings
  • 两人意见不一致,thoseStrings优先

规则

  • 没有清单或任何具体的东西
  • 没有循环

我试过了

Dim result = theseStrings.Union(thoseStrings)
' result = {"true"}

Dim result = theseString.Concat(thoseStrings)
' result = {"true", "true", "true", "true", "true", "false", "true", "false", "false"}
4

1 回答 1

0

解决方案:

Dim result As IEnumerable(Of String) =
    theseStrings.Select(
        Function(value, index) _
            If(thoseStrings(index) IsNot Nothing, thoseString(index), value))

如果可以清理,请发表评论。

于 2013-04-11T04:44:19.717 回答