Insert characters into a string in C#
See the question and my original answer on StackOverflowThis is my proposition, I know it does not looks super sexy, but I believe it's faster (3X faster for the sample string) and requires the exact amount of memory than all the ones using Select, Join, and all that jazz :-)
static string ConvertString(string s)
{
char[] newS = new char[s.Length * 2 + 1];
int i = 0;
do
{
newS[i] = s[i / 2];
if (i == (s.Length * 2 - 2))
break;
i++;
newS[i] = '.';
i++;
}
while (true);
return new string(newS);
}
Plus it does not require the Framework 4.