Saturday, 3 October 2015

Method snippet to remove space between words - asp.net

Leave a Comment
This is the method that can use in c# application or asp.net to remove space between words.

Example :


Hello World  --> HelloWorld

Method 

    /// <summary>  
     /// Method to remove space in a string example : Hello world --> HelloWorld  
     /// </summary>  
     /// <param name="data"></param>  
     /// <returns></returns>  
     public static string removeSpace(string data)  
     {  
       Regex r = new Regex(@"\s+");  
       string _temp = "";  
       _temp = r.Replace(data, @"");  
       return _temp;  
     }  

OR without static

    /// <summary>  
     /// Method to remove space in a string example : Hello world --> HelloWorld  
     /// </summary>  
     /// <param name="data"></param>  
     /// <returns></returns>  
     public string removeSpace(string data)  
     {  
       Regex r = new Regex(@"\s+");  
       string _temp = "";  
       _temp = r.Replace(data, @"");  
       return _temp;  
     }  




By
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

Subscribe to our newsletter to get the latest updates to your inbox.

Your email address is safe with us!




Founder of developersnote.com, love programming and help others people. Work as Software Developer. Graduated from UiTM and continue study in Software Engineering at UTMSpace. Follow him on Twitter , or Facebook or .



Powered by Blogger.