Hi all,
What is the best way to compare 2 (large) ArrayLists filled with an object.
Can you please help me?
Gaby 4 7559
Hi,
What you mean with "filled with an object" ?
If the array is of a user defined type I th ink that first it depend of how
you want it to compare them, you could compare if both arrays have the same
references, if so all you have to do is a foreach.
If you want to compare the objects itself it depend of the class.
Also remember to check for the size to be equal.
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Gaby" <Ga**@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com... Hi all,
What is the best way to compare 2 (large) ArrayLists filled with an object. Can you please help me?
Gaby
Hi,
I need to compare 2 array lists with the same object type (cAddress).
public class cAddress
{
public string Address = "";
public string Number = "";
public string Zip = "";
public string City = "";
public string Country = "";
public string Telephone = "";
}
Every period the data from the database will be checked against the current
arraylist.
The lists will be filled with aprox 10000 objects.
No I want to know what the best and quickest way is.
Gaby
"Ignacio Machin ( .NET/ C# MVP )" wrote: Hi,
What you mean with "filled with an object" ?
If the array is of a user defined type I th ink that first it depend of how you want it to compare them, you could compare if both arrays have the same references, if so all you have to do is a foreach.
If you want to compare the objects itself it depend of the class.
Also remember to check for the size to be equal.
cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation "Gaby" <Ga**@discussions.microsoft.com> wrote in message news:34**********************************@microsof t.com... Hi all,
What is the best way to compare 2 (large) ArrayLists filled with an object. Can you please help me?
Gaby
First step, make cAddress objects comparable. Basically, this means to
implement the IComparable interface (that is, define a CompareTo method for
it). You may also wnat to define an operator== for it.
Next, I'm going to assume that Current[i] corresponds to Database[i], in
which case it, it's just:
for(int i =0; i< Current.Length, ++i)
{
cAddress ad1 = Current[i];
cAddress ad2 = Database[i];
if (ad1.CompareTo(ad2) != 0)
return "Don't Match";
}
return "Match";
--
--
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
"Gaby" <Ga**@discussions.microsoft.com> wrote in message
news:BA**********************************@microsof t.com... Hi,
I need to compare 2 array lists with the same object type (cAddress). public class cAddress { public string Address = ""; public string Number = ""; public string Zip = ""; public string City = ""; public string Country = ""; public string Telephone = ""; }
Every period the data from the database will be checked against the
current arraylist. The lists will be filled with aprox 10000 objects. No I want to know what the best and quickest way is.
Gaby "Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,
What you mean with "filled with an object" ?
If the array is of a user defined type I th ink that first it depend of
how you want it to compare them, you could compare if both arrays have the
same references, if so all you have to do is a foreach.
If you want to compare the objects itself it depend of the class.
Also remember to check for the size to be equal.
cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation "Gaby" <Ga**@discussions.microsoft.com> wrote in message news:34**********************************@microsof t.com... Hi all,
What is the best way to compare 2 (large) ArrayLists filled with an object. Can you please help me?
Gaby
cheers....
"James Curran" wrote: First step, make cAddress objects comparable. Basically, this means to implement the IComparable interface (that is, define a CompareTo method for it). You may also wnat to define an operator== for it.
Next, I'm going to assume that Current[i] corresponds to Database[i], in which case it, it's just:
for(int i =0; i< Current.Length, ++i) { cAddress ad1 = Current[i]; cAddress ad2 = Database[i]; if (ad1.CompareTo(ad2) != 0) return "Don't Match"; } return "Match";
-- -- Truth, James Curran [erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com Blog: www.honestillusion.com Day Job: www.partsearch.com
"Gaby" <Ga**@discussions.microsoft.com> wrote in message news:BA**********************************@microsof t.com... Hi,
I need to compare 2 array lists with the same object type (cAddress). public class cAddress { public string Address = ""; public string Number = ""; public string Zip = ""; public string City = ""; public string Country = ""; public string Telephone = ""; }
Every period the data from the database will be checked against the current arraylist. The lists will be filled with aprox 10000 objects. No I want to know what the best and quickest way is.
Gaby "Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,
What you mean with "filled with an object" ?
If the array is of a user defined type I th ink that first it depend of how you want it to compare them, you could compare if both arrays have the same references, if so all you have to do is a foreach.
If you want to compare the objects itself it depend of the class.
Also remember to check for the size to be equal.
cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation "Gaby" <Ga**@discussions.microsoft.com> wrote in message news:34**********************************@microsof t.com... > Hi all, > > What is the best way to compare 2 (large) ArrayLists filled with an > object. > Can you please help me? > > Gaby This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tom Szabo |
last post by:
Just wandering how can you close a browser remotely. In some web
applications the browser closes or refreshes periodically.
How is that done and how can it be done through PHP?
TIA,
Tom
|
by: Reid Nichol |
last post by:
Hello,
I was wondering if I could control how many bytes are in an int and
the byte order. In C/C++ I can use int32 but how do I do this in
python? How can I control byte order?
|
by: v I n O |
last post by:
hI Geeks
Please do let me know how do i find how many instances sql server
running on the single machine. or in the n/w my objective should with
help of C#/vb.net
|
by: James Salisbury |
last post by:
Hi,
I was checking my parent's website salisbury.cabrera.net on google by
entering villa rent spain cabrera I can see the required site, ranked at 4,
but I am concerend by the return at 1 and 5...
|
by: Frances Del Rio |
last post by:
http://www.emol.com/especiales/cocina_chilena/comida.asp
this page is so neat (goes in pop-up..) how was this done? how do you
give a layer (or div, I guess) a semi-transparency so you can still...
|
by: |
last post by:
Developing, building, and testing. How do it the best? Learning from the
world leader - Microsoft
I'm very interested in how the developing/build/testing workflow @ Microsoft
looks like. I...
|
by: Supra |
last post by:
in vb6
listbox1.remove item 5
how will i do in vb.net?
regards
|
by: anushhprabu |
last post by:
#define q(k)main(){ return!puts(#k"\nPRABUq("#k")");}
q(#define q(k)main(){return!puts(#k"\nq("#k")");})
guys i'm working on this code.. i got it fromnet.. how this is working.. anyone pls.....
|
by: candra |
last post by:
Learn What Hackers Know?
-General Hacking Information
-Password Security
-Scanning, Fingerprinting And Similar Techniques
-How Hackers Attack Numerous Internet Services
-How Hackers Attack Web...
|
by: belred |
last post by:
i just read this blog about how many objects (types) are loaded for a
hello world program in C#.
http://blogs.msdn.com/abhinaba/archive/2008/09/15/how-many-types-are-loaded-for-hello-world.aspx
...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
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...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |