开发者

LINQ: String.Join a list but add a character to that string beforehand

I have the following list:

  • alpha
  • beta
  • charlie
  • delta

I want to turn these strings into one string, co开发者_如何学Cmma separated, but I want to add a character to them first (the @ symbol). The end result should be: @alpha,@beta,@charlie,@delta

What I have right now is a non-LINQ method, but it doesn't seem "clean":

String.Concat("@", String.Join(",@", mylist));


string.Join(",", mylist.Select(s => "@" + s));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜