I found a lot on the Internet and summarized several methods for your reference:
1. The most used is substring. This is also what I have always used
Copy code code as follows:
s = s.substring (0, s.Length-1)
2. Using RTRIM, I only know that I only know that it is used to delete the final space, and I have not seen other usage carefully. I found that I can directly drop some characters.
Copy code code as follows:
s = s.tostring (). RTRIM (',')
3. Use trimend, this thing is similar to RTRIM. The difference is that this pass is a character array, and RTRIM can be any effective string
Copy code code as follows:
s = s.trimend (',')
// If you want to delete "5,", you need to write this way
char [] mychar = {'5 ′,', ','};
s = s.trimend (mychar);
// s = "1,2,3,4 ″