string thingword=" testing hmmm";
string firstLetter,res tOfWord;
foreach (string word in thingword.Split ())
{
Console.WriteLi ne(word); // if this only use for output and the rest in
the block is commented, no error !!!
firstLetter = word.Substring( 0,1);
restOfWord = word.Substring( 1, word.Length -1);
Console.WriteLi ne(firstLetter) ;
Console.WriteLi ne(restOfWord);
}
error:::
Unhandled Exception: System.Argument OutOfRangeExcep tion: Index and length
must r
efer to a location within the string.
Parameter name: length
at System.String.S ubstring(Int32 startIndex, Int32 length)
at Class1.jimmy.Ma in(String[] what) in c:\documents and settings\jim\my
docum
ents\visual studio projects\consol eapplication1\c lass1.cs:line 43
Press any key to continue
Comment