循环通过特定DataTable的行 [英] Loop through the rows of a particular DataTable

查看:107
本文介绍了循环通过特定DataTable的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IDE:VS 2008,
平台:.NET 3.5,

IDE : VS 2008, Platform : .NET 3.5,

这是我的DataTable列:

Here is my DataTable columns :

ID注意细节

我想像这样写sth:

//below code block is not the right syntax


For each q in dtDataTable.Column("Detail)

    strDetail = Row of Column Detail

 Next

任何人都可以给我一个建议,并给我一个代码示例吗?谢谢。

Can anyone give me a suggestion and show me a code sample please ? Thanks.

推荐答案

For Each row As DataRow In dtDataTable.Rows
    strDetail = row.Item("Detail")
Next row

还有一个简写:

For Each row As DataRow In dtDataTable.Rows
    strDetail = row("Detail")
Next row

注意微软现在的风格指南现在专门建议不要使用匈牙利类型的前缀作为变体ables而不是strDetail,例如,你应该使用Detail。

Note that Microsoft's style guidelines for .Net now specifically recommend against using hungarian type prefixes for variables. Instead of "strDetail", for example, you should just use "Detail".

这篇关于循环通过特定DataTable的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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