Clean Spaces from String - CSharp System

CSharp examples for System:String Format

Description

Clean Spaces from String

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Linq;
using System.Globalization;
using System;//from  w  w  w .j  a v a 2s .  c om

public class Main{
        public static string CleanSpaces(this string text)
        {
            return CollapseSpace.Replace(text, " ").Trim();
        }
        public static string Replace(this string text, int index, int length, string replacement)
        {
            text = text.Remove(index, length);
            text = text.Insert(index, replacement);
            return text;
        }
}

Related Tutorials