这样List<>怎么改成Arraylist
List <SqlParameter> paraList = new List <SqlParameter> (new SqlParameter[] {new SqlParameter( "@userid ",userId),
new SqlParameter( "@firstname ",firstName),new SqlParameter( "@lastname ",lastName),
new SqlParameter( "@role ",role),new SqlParameter( "@failedattempts ",failedAttempts)});
if (password != string.Empty)
{
paraList.Add(new SqlParameter( "@password ", password));
}
SqlParameter[] parameters = paraList.ToArray();
SqlHelper.ExecuteNonQuery( "user_updateuser ", parameters);
List 在 Framework 2.0 中能用,但是在1.1的版本中就找不到
我现在用的是1.1
上面的代码如何如何转换,请朋友帮个忙
对了 SqlHelper好象也是2.0中的,在1.1中如何改写
谢谢先
------解决方案--------------------ArrayList paraList = new ArrayList(new SqlParameter[] {new SqlParameter( "@userid ",userId),
new SqlParameter( "@firstname ",firstName),new SqlParameter( "@lastname ",lastName),
new SqlParameter( "@role ",role),new SqlParameter( "@failedattempts ",failedAttempts)});
if (password != string.Empty)
{
paraList.Add(new SqlParameter( "@password ", password));
}
SqlParameter[] parameters = paraList.ToArray(typeof(SqlParameter));
SqlHelper.ExecuteNonQuery( "user_updateuser ", parameters);
------解决方案--------------------//SqlParameter[] parameters = paraList.ToArray(typeof(SqlParameter));
//这句错了~~
//要这样
SqlParameter[] parameters = new SqlParameter[paraList.Count];
for (int i = 0; i < paraList.Count; i++) {
parameters[i] = (SqlParameter)paraList[i];
}
------解决方案--------------------Array.Copy( paraList.ToArray , parameters , .... );
------解决方案--------------------Array.Copy( paraList.ToArray , parameters , .... );
正解