Hello, Juziinfo!

m0o0mbao

导航

数组和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())

posted on 2015-07-21 11:33  m0o0mbao  阅读(247)  评论(0编辑  收藏  举报