foreach(dt.rows中的DataRow dr) [英] foreach (DataRow dr in dt.Rows)

查看:58
本文介绍了foreach(dt.rows中的DataRow dr)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

foreach (DataRow dr in dt.Rows)
{
}


您能解释一下检查此foreach循环的内容吗?
我在for和foreach之间有些困惑,解释wt是for和foreach之间的区别.


Can u explain what checks this foreach loop?
I am a little confuse between for and foreach, explain wt is difference betweeen for and foreach.

推荐答案

尝试使用此链接
Try this link Foreach-Loop-VS-For-Loop with example of data row[^]


Well foreach取得了一个集合中的一个对象,并根据对象的索引获取For循环.

就像如果您想为同一场景申请循环,那么

Well foreach fetched one by one object among the collection and For loop fetched based on index of object.

Like if you want to apply for loop for the same scenario then

For(int i=0;i<dt.rows.count;i++)
{
DataRow row = dt.rows[i];
}



我在应获取索引的对象上扮演着重要角色.而在foreach中,它从集合中一一抓取对象.

thatraja提供的文章不错,但缺乏理解,可能会
[ ^ ]将以更好的方式为您提供帮助理解它.



Where i Plays an important role that on object at which index should be fetched. and while in foreach it grabs one by one object from the collection.

Article provided by thatraja is good but it lacks understanding may THIS[^] will help you in better way to understand it.



for循环在条件上运行,并将一直运行到
条件为假.通常这是一个柜台,而
条件是一个门槛.

例如(int i = 0; i< dt.Rows.count; i ++)
{
}
在此处运行计数器,直到未设置i< dt.Rows.count.
因此,在这里您可以输入任意数量的条件.

foreach遍历数组

的每个元素在循环中执行一次代码 数组,带有数组元素.

例如
foreach(在dt.rows中的DataRow dr)
{
}

在这里,博士检查了dt.rows
Hi,
A for loop is run on a condition, and will run until the
condition is false. Usually this is a counter, and the
condition is a threshold.

Ex for(int i=0;i<dt.Rows.count;i++)
{
}
Here counter is run until it is not setisfied i<dt.Rows.count.
So here you can take any number for condition.

A foreach runs through an array
executing the code in the the loop once for each element of
the array, with the array element.

Ex .
foreach (DataRow dr in dt.Rows)
{
}

Here dr checks each element of the dt.rows


这篇关于foreach(dt.rows中的DataRow dr)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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