Can you reverse order a string in one line with LINQ or a LAMBDA expression

前端 未结 11 868
暗喜
暗喜 2021-02-02 16:01

Not that I would want to use this practically (for many reasons) but out of strict curiousity I would like to know if there is a way to reverse order a string using LINQ and/or

11条回答
  •  攒了一身酷
    2021-02-02 16:33

    I don't see a practical use for this but just for the sake of fun:

    new string(Enumerable.Range(1, input.Length).Select(i => input[input.Length - i]).ToArray())
    

提交回复
热议问题