如何在VB.NET中循环浏览列表 [英] How to Loop through the List in VB.NET

查看:68
本文介绍了如何在VB.NET中循环浏览列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表,其中充满了从DB提取的数据.

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

我的代码:

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

MyClass如下所示:

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

我正在尝试循环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:

类型"MyClass"的值不能转换为字符串"

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

这里出什么问题了?有帮助吗?

Whats arong here? Any Help?

谢谢.

推荐答案

尝试一下

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

这篇关于如何在VB.NET中循环浏览列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆