Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove The Space in a String in c#

I want to know how to remove space in a string. For Example take a string a= "Hello World". Once the whitespace is found then "Hello" and "World" Should be Separated and get stored in separate Strings. Like b="Hello" and c="World". It is possible to do. Can anyone help me.

Thanks in advance.

like image 562
bharathi Avatar asked Apr 29 '11 01:04

bharathi


1 Answers

Do a

  var words = a.Split(' ');

This will return an array with each word in one

foreach(var word in words)
{
   Trace.WriteLine(word);
}

http://msdn.microsoft.com/en-us/library/b873y76a.aspx

like image 176
turtlepick Avatar answered Sep 27 '22 15:09

turtlepick