大家进来帮我解释段代码。字典跟哈希表
public bool Insert(String TableName,Hashtable Cols) //TableName = Topic Cols count = 5
{
int Count = 0;
if (Cols.Count<=0)
{
return true;
}
String Fields = " (";
String Values = " Values(";
foreach(DictionaryEntry item in Cols)
{
if (Count!=0)
{
Fields += ",";
Values += ",";
}
Fields += item.Key.ToString();//字段名 "(Title"
Values += item.Value.ToString();//字段值 "Values('123'"
Count ++;
}
Fields += ")";
Values += ")";
String SqlString = "Insert into "+TableName+Fields+Values;
return Convert.ToBoolean(ExecuteSQL(SqlString));
}
这里面的foreach(DictionaryEntry item in Cols) 是什么意思?