c# - Insert into a certain position in a string -


i found this question insert characters position string, possible insert character string variable length?

for example; want insert substring s = c + separator existing string this:

string c = "c"; string separator = "-";                                               {s} string1 = "mot1-g-prt45-100"; // "mot1-g-prt45-c-100" 

or this:

string c = "c"; string separator = null;                                         {s}      string2 = "mot1gprt45100"; // "mot1gprt45c100" 

i have looked @ string.insert method don't think can use in instance. have other suggestions might able use?

note: part of string remains same there always 3-digit number on end of string.

this should work:

string s = "mot1-g-prt45-100"; int index = ... // position insert string res = s.insert(index, c + separator); 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -