Concating String Array with semicolons

后端 未结 2 1700
隐瞒了意图╮
隐瞒了意图╮ 2021-01-27 02:25

It is a pattern that occurs quite often in one part of our Framework. Given an Array of Strings, we have to concat all of them, seperated by Semicolons.

I´d like to know

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-27 02:49

    You can use string.Join():

    String[] values = new String[] {"a","b","c","d"};
    var concat = string.Join(", ", values);
    

    This will result in something looking like this:

    a, b, c, d

提交回复
热议问题