如何从数据表中获取行号?

编程入门 行业动态 更新时间:2024-10-10 17:23:20
本文介绍了如何从数据表中获取行号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在遍历数据表中的每一行:

I am looping through every row in a datatable:

foreach (DataRow row in dt.Rows) {}

我想获取dt数据表中当前行的索引。例如:

I would like to get the index of the current row within the dt datatable. for example:

int index = dt.Rows[current row number]

我该怎么做?

推荐答案

int index = dt.Rows.IndexOf(row);

但是您最好使用for循环而不是foreach。

But you're probably better off using a for loop instead of foreach.

更多推荐

如何从数据表中获取行号?

本文发布于:2023-11-05 03:03:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559734.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:行号   数据表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!