1
我定義了諸如如何轉換ListItemCollection列出
Public Class MyClass
Public Type1 As Integer
Public Type2 As float
End Class
一類我怎麼能轉換ListItemCollection到(MyClass的的)的列表(對象)?
我定義了諸如如何轉換ListItemCollection列出
Public Class MyClass
Public Type1 As Integer
Public Type2 As float
End Class
一類我怎麼能轉換ListItemCollection到(MyClass的的)的列表(對象)?
MyClass
的是在VB.NET關鍵字和float
型經由Single
別名(System.Single)
Public Class Item
Public Type1 As Integer
Public Type2 As Single
End Class
我已經構建表達收集與樣品數據。
Dim cl As New ListItemCollection
cl.Add(New ListItem("1", "1.2"))
cl.Add(New ListItem("2", "2.3"))
cl.Add(New ListItem("3", "3.4"))
Dim lst = From ele In cl Select New _
Item With
{
.Type1 = Integer.Parse(ele.Text),
.Type2 = Single.Parse(ele.Value)
}
For Each ele As Item In lst
Response.Write("<br/> " & ele.Type1 & " " & ele.Type2)
Next
Dim x As New List(of [MyClass])
For Each y as [MyClass] in ListItemCollectionInstance.Items
if (y.Selected)
x.Add(y)
Next y
使用LINQ:
Dim selectedItems As List(Of [MyClass]) = ListItemCollectionInstance.Items.Cast(Of [MyClass])().Where(Function(itm) itm.Selected = True).ToList()
這是網絡還是winform應用程序? – adatapost 2012-07-26 10:35:02
它的webmethod – 2012-07-26 10:38:52
@ user1460625&AVD:看看標籤,說asp.net ... – 2012-07-26 10:45:46