Remove the last three characters from a string

前端 未结 14 1569
南方客
南方客 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:52

    I read through all these, but wanted something a bit more elegant. Just to remove a certain number of characters from the end of a string:

    string.Concat("hello".Reverse().Skip(3).Reverse());
    

    output:

    "he"
    

提交回复
热议问题