473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Compare arraylist

1
Hi.
I would like to ask how to compare three or more Arraylists?
I need to dublicate ellements from Arraylists, in order to filter datagridview.
I would like to choose from 1 to 5 Arraylists. I know how to compare two Aarraylists.
Jun 22 '09 #1
3 2517
tlhintoq
3,525 Expert 2GB
Would this make sense/work for you?

Compare A-B
Compare B-C
Compare C-D
Compare D-E
Jun 22 '09 #2
PRR
750 Expert 512MB
Look into ArrayList contains and equals method

Expand|Select|Wrap|Line Numbers
  1. public static void CompareArrayList()
  2.         {
  3.             ArrayList al = new ArrayList();
  4.             al.Add(1);
  5.             al.Add("2");
  6.  
  7.             ArrayList al1 = new ArrayList();
  8.             al1.Add(1);
  9.             al1.Add("2");
  10.  
  11.             bool isEqual = true ;
  12.  
  13.             if (al.Count == al1.Count)
  14.             {
  15.                 for(int i=0;i<al.Count;i++)
  16.                 {
  17.                     if (al[i] .Equals( al1[i])==false)
  18.                     {
  19.                         isEqual = false;
  20.                         break;
  21.                     }
  22.                 }
  23.            }
  24. // OR you could use Contains method
  25. if (al.Count == al1.Count)
  26.             {
  27.                 for (int i = 0; i < al.Count; i++)
  28.                 {
  29.                     if (al1.Contains(al[i])==false)
  30.                     {
  31.                         isEqual = false;
  32.                         break;                        
  33.                     }
  34.                }
  35.           }
  36.        }
  37.  
  38.  
Jun 23 '09 #3
r035198x
13,262 8TB
Your description doesn't really say what you want to do.
Why not post an example of input lists and expected output from those input lists.
Jun 24 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: David zhu | last post by:
I've got different result when comparing two strings using "==" and string.Compare(). The two strings seems to have same value "1202002" in the quick watch, and both have the same length 7 which I...
1
by: bengamin | last post by:
Hi, I declare two ArrayList variables.How can I compare if the two ArrayList are Value Equal. Thanks! Ben
4
by: Sasidhar Parvatham | last post by:
Hi All, How do I compare two strings and get all the positions where there is a difference between them? Thanks, Sasidhar
4
by: Gaby | last post by:
Hi all, What is the best way to compare 2 (large) ArrayLists filled with an object. Can you please help me? Gaby
7
by: Terry | last post by:
I've got a situation where I have a set of data, and later take another snapshot to obtain a second set of data. There will be one or more changes in the second set of data and I need to be able...
0
by: jrthor2 | last post by:
I have a .net application that is using microsofts locator service. I have this working, but when I select a user to locate from my contact list, it comes back with a map, but the pushpin has the...
3
by: Sam | last post by:
Hi Everyone, I have a stucture below stored in an arraylist and I want to check user's input (point x,y) to make sure there is no duplicate point x,y entered (string label can be duplicated). Is...
27
by: sandyw | last post by:
Hi Everyone. Need some help. I have no ideal how to start this. my arlist is as followed static ArrayList arlist; arlist = new ArrayList<ticket>() I do not know where to go after this how do...
3
by: raylopez99 | last post by:
This is an example of using multiple comparison criteria for IComparer/ Compare/CompareTo for List<and Array. Adapted from David Hayden's tutorial found on the net, but he used ArrayList so the...
5
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I have a Container that is an an Array List of Class Each ArrayList element can be the class or a another ArrayList of Class So there the ArrayList could look like Element 1 - Class...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.