The problem I am having is that I need to be able to loop over a string, returning 5 characters after the position of the index, then starting 5 characters after.
However when there are less than 5 characters left an out of range error occurs, I thought it would just print the remaining characters of the string.
string string1 = "ghuitghtruighr";
for (int index = 0; index < string1.Length; index += 5)
string subString = string1.Substring(i, 5);
How can I get it to print what's left of the string when whats remaining is less than 5?