Remove the last three characters from a string

前端 未结 14 1565
南方客
南方客 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 16:06

    items.Remove(items.Length - 3)
    

    string.Remove() removes all items from that index to the end. items.length - 3 gets the index 3 chars from the end

提交回复
热议问题