我有excel VBA脚本:
Set c?nn = CreateObject("ADODB.Connection")
conn.Open "report"
Set rs = conn.Execute("select * from table" )
Run Code Online (Sandbox Code Playgroud)
脚本工作正常,但我想添加参数.例如"where(parentid = myparam)",其中myparam在查询字符串外设置.我该怎么做?
当然我可以修改查询字符串,但我认为这不是很明智.
我有 C# 代码:
string[] names = new [] { "a", "b", "c" };
int[] vals = new[] { 5, 10, 15 };
r = "";
for( int i = 0; i < names.Length; i++ )
r += names[i] + ": " + vals[i] + " ";
Run Code Online (Sandbox Code Playgroud)
在 python 中我可以写 oneliner
r = " ".join( [ names[i] + ":" + str(vals[i]) for i in range(len(names)) ] )
Run Code Online (Sandbox Code Playgroud)
我怎样才能在 C# 中做到这一点?