Actually, if you want to use a StringBuilder, there is an overload of the
StringBuilder.Replace() method that takes an index and a count. Example:
StringBuilder sb = new StringBuilder("AAAAAAAAAAAAAAAAAAAA");
return sb.Replace(sb.ToString().Substring(3, 14),
"ZZZZZZZZZZZZZZ").ToString();
// returns "AAAZZZZZZZZZZZZZZAAA"
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
"Bruce Wood" <br*******@canada.com> wrote in message
news:11********************@g43g2000cwa.googlegrou ps.com...
No.
Depending upon what you want, you would have to code either:
string modified = original.Substring(0, 2) + "Z" + original.Length > 17
? original.Substring(17) : "";
or
StringBuilder sb = new StringBuilder(original.Substring(0,2));
for (int i = 2; i < Math.Min(17, original.Length); i++)
{
sb.Append("Z");
}
if (original.Length > 17)
{
sb.Append(original.Substring(17));
}
string modified = sb.ToString();
or something like that. :)