Sorry as the question is bit lengthy.
I have this string "Hello how are you"
When I pass it to this function in ASP.Net C#
private void separateSpaces(string text)
{
string[] separatedWords = text.Split(' ');
for(int i=0;i<separatedWords.length;i++)
{
Response.Write("<br>"+separatedWords[$i]);
}
}
When I run that string to this function , I get my expected answer perfectly. Like
Hello
how
are
you
But when I subject this text. I am getting a wrong output
This is the text
Fusion Technologies, Hyderabad, India May 2005 – July 2007
Net Developer
Everything breaks fine , except for
India May
it is treated as a string together. I need both of them to be separate
Maybe
India Mayis treated as single string because there’s no space between them (and for example other whitespace, like\t)?Try this and see whether it works:
The
default(string[])is simplynull. WhenString.Splitreceivesnullas first argument, it treats all whitespace characters (matched byChar.IsWhiteSpace) as delimeters.