How to insert spaces between the characters of a string

后端 未结 4 577
醉酒成梦
醉酒成梦 2021-01-14 08:01

Is there an easy method to insert spaces between the characters of a string? I\'m using the below code which takes a string (for example ( UI$.EmployeeHours * UI.DailySalar

4条回答
  •  隐瞒了意图╮
    2021-01-14 08:35

    Here is a short way to insert spaces after every single character in a string (which I know isn't exactly what you were asking for):

    var withSpaces = withoutSpaces.Aggregate(string.Empty, (c, i) => c + i + ' ');
    

    This generates a string the same as the first, except with a space after each character (including the last character).

提交回复
热议问题