I'm trying to complete a practice assignment that was due a few weeks ago(not graded), and I cannot for the life of me figure it out what is wrong. I need the output to be " 1 The 2 quick 3 brown 4 fox 5 jumps 6 over 7 the 8 lazy 9 dog" I have the split string so I can get all the words down, just cannot get the numbers before it. so far I have this
int ctr = 0;
string sentance = "The quick brown fox jumped over the lazy dog. ";
string[] split = sentance.Split(new char[] { ' ', '.' });
foreach (string s in split)
{
if (s.Trim() != "")
Console.WriteLine("{0} {2}", ctr++, s);
}
Console.ReadLine();
All I keep getting is an unhandled exception, and I cannot find out why.
System.FormatException) in your question. unhandled just mentioned there is an exceptionstring.IsNullOrWhiteSpace