我有这组常量。
private const string A1KEY = 'a1';
private const string A1VALUE = 'AONE';
private const string B1KEY = 'b1';
private const string B1VALUE = 'BONE';
private const string C1KEY = 'c1';
private const string C1VALUE = 'CONE';
private const string D1KEY = 'd1';
private const string D1VALUE = 'DONE';
我收到了表格的输入。
string input = 'a1,b1,d1';
所以,根据这个输入......我的目标是生成一个动态脚本,该脚本将包含输入中接收到的键的相应值。
我打算 ,
1)将键值对添加到字典中。
2) 将字典键与输入字符串进行比较。
3) 为收到的键选择相应的值。
4)并将该列表发送到生成脚本的方法。
public string GenerateDynamicScript (...)
{
StringBuilder appndScript = new StringBuilder();
appndScript.Append ("alert('the value is <variable>'"); }
这是一个正确的方法吗?代码示例会很有帮助。
处理这个目标的有效方法是什么?