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

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

    If we need to support combining characters and surrogate pairs:

    // This method tries to handle:
    // (1) Combining characters
    // These are two or more Unicode characters that are combined into one glyph.
    // For example, try reversing "Not nai\u0308ve.". The diaresis (¨) should stay over the i, not move to the v.
    // (2) Surrogate pairs
    // These are Unicode characters whose code points exceed U+FFFF (so are not in "plane 0").
    // To be represented with 16-bit 'char' values (which are really UTF-16 code units), one character needs *two* char values, a so-called surrogate pair.
    // For example, try "The sphere \U0001D54A and the torus \U0001D54B.". The 

提交回复
热议问题