数组和ArrayList 相互转换

Dim params(10) As DbParameter

params(0) = DBHelper.CreateDbParameter("@RegName", Jz_RegInfo.RegName)
params(1) = DBHelper.CreateDbParameter("@RegAddress", Jz_RegInfo.RegAddress)
params(2) = DBHelper.CreateDbParameter("@RegCode", Jz_RegInfo.RegCode)
params(3) = DBHelper.CreateDbParameter("@CutOFFDate", Jz_RegInfo.CutOFFDate)
params(4) = DBHelper.CreateDbParameter("@IsZhengShi", Jz_RegInfo.IsZhengShi)
params(5) = DBHelper.CreateDbParameter("@RegDateTime", Jz_RegInfo.RegDateTime)
params(6) = DBHelper.CreateDbParameter("@ClientID", Jz_RegInfo.ClientID)
params(7) = DBHelper.CreateDbParameter("@Xian", Jz_RegInfo.Xian)
params(8) = DBHelper.CreateDbParameter("@Shi", Jz_RegInfo.Shi)
params(9) = DBHelper.CreateDbParameter("@IsDeleted", Jz_RegInfo.IsDeleted)
params(10) = DBHelper.CreateDbParameter("@Remark", Jz_RegInfo.Remark)

Dim arrayPara As New ArrayList()  
arrayPara.AddRange(params)

ArrayList 转换为数组的方法:

数组  as  类型()  =ArrayList.ToArray (GetType(类型))

Dim arr As DbParameter() = arrayPara.ToArray(GetType(DbParameter))
 Dim Array  As DbParameter() = DirectCast(arrayPara.ToArray(GetType(DbParameter)), DbParameter())

上一篇:以不同用户身份运行程序,/savecred只需要输入一次密码(GetTokenByName取得EXPLORER.EXE的令牌,然后调用CreateProcessAsUser,而且使用LoadUserProfile解决另存文件的问题)good


下一篇:如何自动以管理员身份运行.NET程序?