我有一个带有 2 个占位符的字符串,我想根据值计算在运行时替换它。做这个的最好方式是什么。我已使用下面的代码进行单个占位符替换,
String posttData = @"data = google.visualization.arrayToDataTable([
['Label', 'Value'],
['Result', {0}]
]);
var options = {
width: 1200, height: 500, redFrom: 90, redTo: 100, yellowFrom: 75, yellowTo: 90, minorTicks: 5
};
....结果计算
var x = posttData.Replace("{0}", result.ToString());
ScriptManager.RegisterStartupScript(this, this.GetType(), "test", x, true);
如何对多个替换执行相同操作?如果我需要添加另一个选项,
var options = {
width: 1200, height: 500, redFrom: 90, redTo: 100, yellowFrom: 75, yellowTo: 90, minorTicks: 5, max: {1}