What is the easiest way in C# to trim a newline off of a string? -
I want to make sure that _content does not end with a newLine character:
< Code> _content = Sb.ToString (). Trim (new four [] {environment. Newline});
But the code above does not work because the trim does not have overloaded parameters for the collection of stars, only characters are.
What is the simple one-liner to remove an environment from the end of a string?
does the following for me.
sb.ToString (). TrimEnd ('\ r', '\ n');
or
sb.ToString (). TrimEnd (EnvironmentalNewLine.ToCharArray ());
Comments
Post a Comment