如何比较 2 个数据表 [英] How to compare 2 dataTables

查看:15
本文介绍了如何比较 2 个数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 2 个数据表,我只想知道它们是否相同.相同"是指它们的行数是否完全相同,每列中的数据是否完全相同.我很想编写(找到)一个接受两个表并返回一个布尔值的方法.

I have 2 datatables and I just want to know if they are the same or not. By "the same", I mean do they have exactly the same number of rows with exactly the same data in each column, or not. I'd love to write (find) a method which accepts both tables and returns a boolean.

如何以这种方式比较 2 个数据表?两者都具有相同的架构.

How can I compare 2 datatables in this way? Both have identical schemas.

推荐答案

您需要遍历每个表的行,然后遍历该循环中的每一列以比较各个值.

You would need to loop through the rows of each table, and then through each column within that loop to compare individual values.

这里有一个代码示例:http://canlu.blogspot.com/2009/05/how-to-compare-two-datatables-in-adonet.html

这篇关于如何比较 2 个数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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