I need to get the id into the string with comma from the object. I used linq but the string is
System.Linq.Enumerable+WhereSelectEnumerableIterator`2[item,System.Int32]
There are my two objects:
Public Class Items
Implements IEnumerable
Private _ID As Integer
Private desc As String
Private arrItemList As New ArrayList
Public Property ID() As Integer
Get
Return _ID
End Get
Set(ByVal Value As Integer)
_ID = Value
End Set
End Property
Public ReadOnly Property Count() As Integer
Get
Return arrItemList.Count
End Get
End Property
Public Sub AddProduct(ByVal obj As item)
arrItemList.Add(obj)
End Sub
Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
Return arrItemList.GetEnumerator()
End Function
End Class
Public Class item
Public Property ID As Integer
Public Property desc As String
End Class
There are my code to get the ID into the string.
Dim objItems As New Items()
objItems.AddProduct(New item With {.ID = 1, .desc = "orange"})
objItems.AddProduct(New item With {.ID = 2, .desc = "apple"})
objItems.AddProduct(New item With {.ID = 3, .desc = "peach"})
Dim query = objItems.Cast(Of item)().Select(Function(o) o.ID)
Dim result As String = String.Join(",", query)
ArrayListat all, your code should work fine. There is no need to useo.Id.ToStringinstead of usingo.Idunless you don't use a very old version of the .NET framework.