You can use the helpful extension method from this question (second answer down) ReplaceFirst
:
public static string ReplaceFirst(this string text, string search, string replace)
{
int pos = text.IndexOf(search);
if (pos < 0)
{
return text;
}
return $"{text.Substring(0, pos)}{replace}{text.Substring(pos + search.Length)}";
}
and then call it like this
var reason = "%s与%s等预算科目的内容存在重复,核减%d万元";
var results1 = "本科目镍铁中多元素样品前处理";
var results2 = "本科目ICP测定法";
var resultd = "2.50";
var final = reason
.ReplaceFirst("%s", results1)
.ReplaceFirst("%s", results2)
.ReplaceFirst("%d", resultd);
Where final
is assigned
"本科目镍铁中多元素样品前处理与本科目ICP测定法等预算科目的内容存在重复,核减2.50万元"