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

前端 未结 11 873
暗喜
暗喜 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:26

    In addition to one previous post here is a more performant solution.

    var actual0 = "reverse me".Aggregate(new StringBuilder(), (x, y) => x.Insert(0, y)).ToString();
    

提交回复
热议问题