Santosh
Santosh

Reputation: 2515

How to Loop through the List in VB.NET

I have a list which is filled with a data fetched from DB.

My Code:

 Dim lst As New List(Of MyClass)
 lst = GetData()

MyClass looks like the following:

Public Class MyClass
   Public Overridable Property Id as Integer
   Public Overridable Property Questions as String
   Public Overridable Property Comments as String
End Class

I am trying to loop the lst

 For Each item As String In lst
   'Some data manipulation
 Next

But I am unable to loop it through using the above code.It throws following error:

Value of Type 'MyClass' cannot be converted to 'String'

Whats arong here? Any Help?

Thanks in advance.

Upvotes: 0

Views: 7982

Answers (1)

Marius
Marius

Reputation: 1072

Try this

 For Each item As MyClass In lst
   'Some data manipulation
 Next

Upvotes: 6

Related Questions