Remove extra spaces from string in C#
Strings are commonly used in C#. Sometimes string can contain unwanted spaces in beginning or at end. To remove such spaces we use Trim method.
This method removes extra spaces from start and end of string. Return type of this method is string.
stringFruit = " Apple ";
Fruit = Fruit.Trim();
Console.WriteLine(Fruit);
Output
Apple
Comments
Post a Comment