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

前端 未结 11 978
暗喜
暗喜 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-02 16:19

    string str="a and b";
    string t="";
    
    char[] schar = str.Reverse().ToArray();
    
    foreach (char c in schar )
    {
        test += c.ToString();
    }
    

提交回复
热议问题