Taking away a text from a string

  • Thread starter Thread starter Tomomichi Amano
  • Start date Start date
T

Tomomichi Amano

Hello!
I just asked a question, but it seems my question wasn't clear enough, so
I'll ask again, simply.

How can I take the LAST text (say "\r\n") from a string value??

So, if
string a="Hello!\r\nHow are you?\r\n";
it would become
a="Hello!\r\nHow are you?";

Thank you in advance!
 
As Jon said, with SubString()

string line = "something\r\n";
line = line.Substring(0, line.Length - 2);
 
string a="Hello!\r\nHow are you?\r\n";
it would become
a="Hello!\r\nHow are you?";

You can use the 'TrimEnd' method:

string a="Hello!\r\nHow are you?\r\n";

a= a.TrimEnd( '\r', '\n' );

n!
 
Back
Top