I have this:
string curr = "";
if (emails.SelectedItem != null)
{
for (int i = 0; i <= 19; i++)
{
curr = (emails.SelectedItem.ToString()[i] + "." +
emails.SelectedItem.ToString()[i + 1]);
clone.Items.Add(curr);
}
}
However, whenever I run it, it gives me the “index was out of bounds of the array” error.
Why? What’s the fix?
Also, how do I make it add the rest of the string (not just i + 1) to clone?
EXPLANATION OF CODE:
I’m trying to insert a period (.) after one letter of the word, then add it to clone. After that, I want to add a period after the SECOND letter, add to clone, period after third letter, add, etc…
However, I don’t want to have it be t.h.i.s.i.s.t.h.e.n.a.m.e, I want it to just have one period at a time.
It should look like:
a.ntimatter
an.timatter
ant.imatter
anti.matter
etc…
1 Answer