Hey u have to declare the word2 inside the for loop so u the scope of word2 will be confined to that loop u cannot use it outside of that loop... okeee........
so declare word2 int the function scope...
and u have used substring function.. which goes out of range... and throws StringIndexOutOfRangeException.... substring function takes two parameters are .. one is starting position in the string and no of characters to be retrieved... okeee u'r give start position as stringlength-1 and retrieving stringlength + 1 no of characters...