Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Compare (string) content from 2 datasets -- a dataTable and an array -- do I use lists or string vars?

$
0
0

Lets' say I pull data from a sql server table into a local data table

fld1   fld2   fld3
  a1    a2     a3
  b1    b2     b3
  c1    c2     c3

Here is the data content from my array

  a1    a2     a3
  b1    b2     b3
  c1    c2     c3

I want to compare the two data sets against each other (all string content) to see if they contain the same data.  I was thinking I may want to add these contents to List1 and List2 and compare the lists -- or would it be better to add the contents to a couple of string vars?  If this is a good approach then I have 2 questions:

1) Do I need to loop through each dataset (loop through the rows in the table and the rows in the array) and add the strings to a list or string vars or is there Linq that can do this?

2) what is the correct way to compare 2 such lists?   Does List1 = List2?  or str1 = str2

If this approach is not the ideal approach I would be grateful for suggestions of a better way, otherwise, I would be grateful if someone could share a good technique for creating/comparing some structure for comparing the contents from these datasets.

Thanks in advance


Rich P


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>