The idea of params (which always has to be the last decalared parameter in a function can be unlimited for example
Function Foo(string s,params Object[] alist)
{
//whatever
}
Cats cat = new Cats();//I put an object here because cat is an object, if it was ints they would all have to be ints
Foo("ok",cat);
Foo("ok", cat,cat,cat,cat,cat,cat);
are both valid
是这个想法,但你会想要传递 SQL 参数,所以......
dt = ExecuteStoreQuery("INSERT INTO STATUS(ITEMTYPE,PRODESC) values(@ITEMTYPE,'@PRODESC')",new SqlParameter("@ITEMTYPE", 2),new SqlParameter("@PRODESC", "Obama sucks"));
或更多的衬里,这样我可以看得更清楚
object[] obj;
obj[0] = new SqlParameter("@ITEMTYPE", 2);
obj[1] = new SqlParameter("@PRODESC", "Obama sucks");
dt = ExecuteStoreQuery("INSERT INTO STATUS(ITEMTYPE,PRODESC) values(@ITEMTYPE,'@PRODESC')",obj);