Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 17th, 2007, 08:23 PM
Authorized User
 
Join Date: Mar 2007
Location: , , .
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


  #2 (permalink)  
Old May 18th, 2007, 10:17 AM
Authorized User
 
Join Date: Mar 2007
Location: , , .
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!!!

 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 01:02 PM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 10:40 PM
IComparer implementation Bob Bedell C# 1 February 6th, 2006 02:28 AM



All times are GMT -4. The time now is 01:16 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.