codice:
string s = "xxxx#xxxxxxxx#xxxxxxxx#xxxxxxxxxx";
int index = 0;
int c = 0;
while (true)
{
index = s.IndexOf("#", index);
if (index < 0) break;
s = s.Remove(index, 1);
s = s.Insert(index,"{"+ c++ +"}");
}
EDIT :
codice:
string s = "xxxx#xxxxxxxx#xxxxxxxx#xxxxxxxxxx";
int index = 0;
int c = 0;
while (true)
{
index = s.IndexOf("#", index);
if (index < 0) break;
StringBuilder sb = new StringBuilder("{");
sb.Append(c++);
sb.Append("}");
s = s.Remove(index, 1);
s = s.Insert(index,sb.ToString());
}
che dici è meglio?