Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 17th, 2007, 07:23 PM
Authorized User
 
Join Date: Mar 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default IComparer Chapter 5 HELP PLEASE

On page 240 we have the following code:

public static List<Comment> GetComments(int articleID)
{
    List<Comment> comments = GetComments(articleID, 0, BizObject.MAXROWS);
    comments.Sort(new CommentComparer("AddedDate ASC"));
    return comments;
}


Now it’s the Sort() method and our custom IComparer that is confusing me here. Now I know we use this Sort() method to sort our generic comments collection, and it will be sorted by the AddedDate property of the comment instances being compared, but I’m not sure how this is happening. Am I right to assume that by creating a new instance of our custom CommentComparer class within the Sort() method that the Compare() method it contains will execute automatically, and that all the comments in the collection are compared automatically using our Compare() method in order to determine the sort order?

If not then serious help needed here as I don’t understand at all how this sort works. Please help.

Thanks


 
Old May 18th, 2007, 09:17 AM
Authorized User
 
Join Date: Mar 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please ignore this post as the extremely helpful author has provided me with the answer. God bless him!!!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 2 - End of chapter exercises whizzkid1892 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 30th, 2008 12:02 PM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM
IComparer implementation Bob Bedell C# 1 February 6th, 2006 02:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.