加入了智能分离器分离器、智能

2023-09-06 19:33:19 作者:杀戮浪者

这是很容易,当然写的,但在C#2010,有一个内置的加入(或类似)方法,只会增加一个分隔符,如果previous和下一个元素都是非空和非空?

It's easy enough to write, of course, but in C# 2010, is there a built-in Join (or similar) method that will only add a separator if both the previous and next elements are non-null and non-empty?

在换句话说 SmartJoin(,,胡德号,罗宾)将产生胡德,罗宾,但 SmartJoin( ,罗宾汉,的String.Empty)会产生简单的劫富济贫。

In other words SmartJoin(", ","Hood","Robin") would produce "Hood, Robin" but SmartJoin(", ", "Robin Hood", string.Empty) would produce simply "Robin Hood".

推荐答案

有没有内置的加入,你所需要的。

There is no built-in join which you need.