Remove the last three characters from a string

前端 未结 14 1528
南方客
南方客 2021-01-30 15:22

I want to remove last three characters from a string:

string myString = \"abcdxxx\"; 

Note that the string is dynamic data.

14条回答
  •  温柔的废话
    2021-01-30 15:55

       string myString = "abcdxxx";
       if (myString.Length<3)
          return;
       string newString=myString.Remove(myString.Length - 3, 3);
    

提交回复
热议问题