Trim last character from a string

后端 未结 14 1412
谎友^
谎友^ 2020-11-29 23:59

I have a string say

\"Hello! world!\" 

I want to do a trim or a remove to take out the ! off world but not off Hello.

14条回答
  •  甜味超标
    2020-11-30 00:55

    string s1 = "Hello! world!"
    string s2 = s1.Substring(0, s1.Length - 1);
    Console.WriteLine(s1);
    Console.WriteLine(s2);
    

提交回复
热议问题