dim objstr as string ="1111|2222|3333|eeee|3333"
Dim objarray As New ArrayList
objarray.Add(objstr.Split("|"))
Dim i As Integer
For i = 0 To objarray.Count
DropDownList1.Items.Add(CStr(objarray(0)(i)))
Next
*******************************************
objarray.Count 为什么没有办法获取 objarray 元素的个数呢?总是为 1
Dim objarray As New ArrayList
objarray.Add(objstr.Split("|"))
Dim i As Integer
For i = 0 To objarray.Count
DropDownList1.Items.Add(CStr(objarray(0)(i)))
Next
*******************************************
objarray.Count 为什么没有办法获取 objarray 元素的个数呢?总是为 1
所以,Count就是1啊!!
objarray 的count就不是1了。
你可以这样啊string sz_Split="|"; string[] str=objstr.Split(sz_Split.ToCharArray());
string数组 不是也可以用的吗 ?
Dim objarray As New ArrayList
Dim strs AS string[]
strs = objstr.Split("|")
foreach(string str in strs)
objarray.Add(str)
objarray.Add(objstr.Split("|"))
Dim i As Integer
For i = 0 To objarray.Count
DropDownList1.Items.Add(CStr(objarray(0)(i)))
Next
*******
dim objstr as string ="1111|2222|3333|eeee|3333"
Dim objarray As New ArrayList
'============================================================
Dim strArray As string() = objstr.Split("|")
Dim i As Integer
For i = 0 To strArray .Count
DropDownList1.Items.Add(strArray(i))
Next
Dim objstr as string ="1111|2222|3333|eeee|3333"
'============================================================
Dim strArray As string() = objstr.Split("|")
Dim i As Integer
For i = 0 To strArray.Count - 1
DropDownList1.Items.Add(strArray(i))
Next
如果要一定要用ArrayList的话 直接用构造函数就可以可以初始化了string strArrayList = "1111|2222|3333|eeee|3333";
ArrayList arrSplit = new ArrayList(strArrayList.Split('|'));
Response.Write(arrSplit.Count.ToString());