【未使用Linq的寫法】
Dim values = New List(Of String)()
For Each item As ListItem In Me.CheckBoxList1.Items
If item.Selected Then
values.Add(item.Value)
End If
Next
Dim result = String.Join(",", values.ToArray(Of String)())
Dim result = String.Join(",", Me.CheckBoxList1.Items.Cast(Of ListItem)() _
.Where(Function(x) x.Selected) _
.[Select](Function(x) x.Value).ToArray())
p.s. Linq需使用.NET Framework 3.5以上的版本