If I were you, I would do that this way :
string oldString = "A=3;B=2;C=5";
Separate each part :
string[] parts = oldString.Split(";");
Use a
Dictionary<string, int>
to store letters and values :
var dic = new Dictionary<string, int>();
foreach (string part in parts) {
string[] sep = part.Split("=");
dic.Add(sep[0], int.Parse(sep[1]);
}
Replace the parts you need to as per your requirements
dic["B"] = 6;
dic["C"] = 7;
Put everything back together
string[] newParts = new string[parts.Length];
int i = 0;
foreach (var kvp in dic) {
string val = string.Format("{0}={1}", kvp.Key, kvp.Value);
newParts[i++] = val;
}
string newString = string.Join(newParts, ";");
That should get you near what you want.
Hope this helps. Regards.