vb.net - C# string replace from position X to Y only -
possible duplicate:
how perform string replacement on subsection of string?
how replace string position x y only, there string method?
input = abcdxyzabcdxyz
string replace input (start position = 3, end position=9, xyz pqr)
xyz position 3 9 should replaced
output = abcdpqrabcdxyz
here extension method create method described:
public static class stringextension { public static string replace(this string basevalue, int start, int length, string oldvalue, string newvalue) { return basevalue.substring(0, start) + basevalue.substring(start, length).replace(oldvalue, newvalue) + basevalue.substring(start + length, basevalue.length - (start + length)); } }
Comments
Post a Comment