How to remove first and last character of a string in C#?

后端 未结 4 1174
醉酒成梦
醉酒成梦 2021-02-12 13:38
String: \"hello to the very tall person I am about to meet\"

What I want it to become is this:

String: hello to the very tall person I          


        
4条回答
  •  半阙折子戏
    2021-02-12 13:55

    If you want to remove any first and last character from the string, then use Substring as suggested by Anish, but if you just want to remove quotes from beginning and the end, just use

    myStr = myStr.Trim('"');
    

    Note: This will remove all leading and trailing occurrences of quotes (docs).

提交回复
热议问题