en
Home Feedback About project

Replace multiple spaces in a string to single space with C#

If you need to replace multiple spaces (double spaces) in a string to single space with C# you can use next string method:

  • public string Replace(string oldValue, string newValue)

Replace - returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string.

To replace multiple spaces to single space using C# see example:

    myString = Regex.Replace(myString, " {2,}", " ");
© 2010-2017
support@texthandler.com
Learn how to replace multiple spaces in a string to single space with C#