日期:2014-05-19  浏览次数:20815 次

params object[] 问题高手帮下忙谢谢!
函数定义了多变量:params   object[]   para,如下:
public   bool   InsertRecordInToTable(string   tableName,params   object[]   para)
{string   flds= " ";
string   vals= " ";
for(int   i=0;i <para.Length;i+=3)
{
flds   +=   para[i+1].ToString()+ ", ";
if   ((bool)para[i])
{
vals   +=   para[i+2].ToString()+ ", ";
}
else
{
vals   +=   " ' "+   para[i+2].ToString().Replace( " ' ", " ")+ " ', ";
}
}
return   ExecuteSql( "insert   into   "+tableName+ "( "+flds.Remove(flds.Length-1,1)+ ")   values( "+vals.Remove(vals.Length-1,1)+ ") ");}

为什么在调用的时候要写成:
this.proxy.InsertRecordInToTable( "t_carparkgroup ", false, "carpark_group_id ",carpark_group_id, false, "carpark_group_name ",carpark_group_name, false, "district_id ",district_id,
true, "total_parking_no ",0, true, "current_parking_no ",0, true, "update_time ",   "sysdate ", true, "setup_time ",   "sysdate ")

那些   false,true是做什么的啊?




------解决方案--------------------
if ((bool)para[i])//每行第一个参数 true or false;
para[i+1] //第二个 string
para[i+2] //第三个 id
------解决方案--------------------
params用于指定参数数目可变的参数.