C # convert string that has ctrl + z for regular string

I have a line like this:

some_string = "A simple demonstration of SMS text messages." + Convert.ToChar (26));

What is an easy way to get rid of char 26?

remember that sometimes some_string has char 26, and sometimes not, and it can be in different positions, so I need to know what is the most universal and easiest way to get rid of char 26?

+3
source share
2 answers

If it can be in different positions (and not just at the end):

someString = someString.Replace("\u001A", "");

, Replace - , , , .

+6

:

some_string.TrimEnd((char)26)

, .

+4

Source: https://habr.com/ru/post/1750224/


All Articles