Click here to Skip to main content
15,897,891 members
Home / Discussions / C#
   

C#

 
GeneralRe: Need help with crystal reports in VS 2008 Pin
eduardods10-Jun-10 20:02
eduardods10-Jun-10 20:02 
AnswerRe: Need help with crystal reports in VS 2008 Pin
V.10-Jun-10 21:11
professionalV.10-Jun-10 21:11 
AnswerRe: Need help with crystal reports in VS 2008 Pin
Mycroft Holmes11-Jun-10 22:04
professionalMycroft Holmes11-Jun-10 22:04 
QuestionHow to add images to a reportviewer ??? Pin
isaacrc8210-Jun-10 13:33
isaacrc8210-Jun-10 13:33 
Questionpopulating a treeview? Pin
User 251249410-Jun-10 6:05
User 251249410-Jun-10 6:05 
AnswerRe: populating a treeview? Pin
Mycroft Holmes11-Jun-10 22:08
professionalMycroft Holmes11-Jun-10 22:08 
QuestionList<T> Comparison [SOLVED] Pin
Paladin200010-Jun-10 4:58
Paladin200010-Jun-10 4:58 
AnswerRe: List Comparison Pin
DaveyM6910-Jun-10 5:10
professionalDaveyM6910-Jun-10 5:10 
An ideal candidate for generics
C#
bool CompareLists<T>(List<T> listA, List<T> listB)
{
    if (listA.Count != listB.Count) 
        return false;
    foreach (T item in listA)
        if (!listB.Contains(item))
            return false;
    return true;
}


Edit: I haven't optimised your code at all - just converted it to accept generics. You should probably null check both parameters - if both are null it's up to you how you want it to return. As this is nothing really to do with an actual class it may be useful to make it static and possibly an extension method if using 3.0 or above.
Dave

If this helped, please vote & accept answer!


Binging is like googling, it just feels dirtier. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

GeneralRe: List Comparison Pin
Paladin200010-Jun-10 5:28
Paladin200010-Jun-10 5:28 
GeneralRe: List Comparison Pin
Hristo-Bojilov10-Jun-10 5:52
Hristo-Bojilov10-Jun-10 5:52 
AnswerRe: List Comparison Pin
Luc Pattyn10-Jun-10 5:30
sitebuilderLuc Pattyn10-Jun-10 5:30 
GeneralRe: List Comparison Pin
Paladin200010-Jun-10 5:39
Paladin200010-Jun-10 5:39 
GeneralRe: List Comparison Pin
#realJSOP10-Jun-10 6:36
professional#realJSOP10-Jun-10 6:36 
AnswerRe: List Comparison Pin
Paladin200010-Jun-10 5:58
Paladin200010-Jun-10 5:58 
GeneralRe: List Comparison Pin
Paladin200010-Jun-10 6:06
Paladin200010-Jun-10 6:06 
GeneralRe: List Comparison Pin
Luc Pattyn10-Jun-10 6:06
sitebuilderLuc Pattyn10-Jun-10 6:06 
AnswerRe: List Comparison Pin
Kevin McFarlane10-Jun-10 10:45
Kevin McFarlane10-Jun-10 10:45 
QuestionGoogle Maps Pin
JohnUSA10-Jun-10 2:53
JohnUSA10-Jun-10 2:53 
AnswerMessage Closed Pin
10-Jun-10 3:06
stancrm10-Jun-10 3:06 
GeneralRe: Google Maps Pin
JohnUSA10-Jun-10 4:45
JohnUSA10-Jun-10 4:45 
AnswerRe: Google Maps Pin
Paladin200010-Jun-10 4:41
Paladin200010-Jun-10 4:41 
GeneralRe: Google Maps Pin
JohnUSA10-Jun-10 4:53
JohnUSA10-Jun-10 4:53 
GeneralRe: Google Maps Pin
Paladin200010-Jun-10 5:20
Paladin200010-Jun-10 5:20 
AnswerRe: Google Maps Pin
Adam R Harris10-Jun-10 4:52
Adam R Harris10-Jun-10 4:52 
QuestionTricky Inheritance Question Pin
Jon Myers10-Jun-10 2:47
Jon Myers10-Jun-10 2:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.