Click here to Skip to main content
15,878,959 members
Home / Discussions / C#
   

C#

 
GeneralRe: Upload Pic... Pin
mjawadkhatri18-Jul-09 0:23
mjawadkhatri18-Jul-09 0:23 
GeneralRe: Upload Pic... Pin
Manas Bhardwaj18-Jul-09 8:20
professionalManas Bhardwaj18-Jul-09 8:20 
QuestionHow to add...... Pin
mjawadkhatri17-Jul-09 18:53
mjawadkhatri17-Jul-09 18:53 
AnswerRe: How to add...... Pin
K030617-Jul-09 19:15
K030617-Jul-09 19:15 
QuestionMultiple Field Sorting C# Pin
dsrao17-Jul-09 18:46
dsrao17-Jul-09 18:46 
AnswerRe: Multiple Field Sorting C# Pin
Uri Lavi17-Jul-09 19:26
Uri Lavi17-Jul-09 19:26 
GeneralRe: Multiple Field Sorting C# Pin
dsrao18-Jul-09 9:12
dsrao18-Jul-09 9:12 
AnswerRe: Multiple Field Sorting C# Pin
riced17-Jul-09 20:49
riced17-Jul-09 20:49 
Use this
public class Item : IComparable
{

   public String Name{get;set;}

   public int Cost{get;set;}
   public Item(string name,int cost)
   {
      Name=name;
      Cost=cost;
   }

   int Icomparable.CompareTo(object obj)
   {
      Item other = (Item) obj;
      If this.Name < other.Name return -1;
      If this.Name > other.Name return 1;
      If this.Cost > other.Cost return 1;
      If this.Cost < other.Cost return -1;
      return 0;
   }
}

Then you can just do items.Sort()
Probably worth having a look at IComparable and IComparer interfaces.
You could alsi look at using List<t> in generics namespace.

Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis

GeneralRe: Multiple Field Sorting C# Pin
Luc Pattyn17-Jul-09 23:55
sitebuilderLuc Pattyn17-Jul-09 23:55 
GeneralRe: Multiple Field Sorting C# Pin
riced18-Jul-09 0:11
riced18-Jul-09 0:11 
GeneralRe: Multiple Field Sorting C# Pin
dsrao18-Jul-09 9:13
dsrao18-Jul-09 9:13 
QuestionProcess.workingset Pin
hpydir17-Jul-09 14:53
hpydir17-Jul-09 14:53 
AnswerRe: Process.workingset Pin
Luc Pattyn17-Jul-09 15:03
sitebuilderLuc Pattyn17-Jul-09 15:03 
Questionhelp Pin
unlucky_dreamer17-Jul-09 12:45
unlucky_dreamer17-Jul-09 12:45 
AnswerRe: help Pin
DaveyM6917-Jul-09 13:20
professionalDaveyM6917-Jul-09 13:20 
GeneralRe: help Pin
Michael Schubert17-Jul-09 22:06
Michael Schubert17-Jul-09 22:06 
QuestionMS Word Automation - Combining word documents Pin
venadder17-Jul-09 11:25
venadder17-Jul-09 11:25 
QuestionDelegates - I don't Get It Pin
eddieangel17-Jul-09 7:52
eddieangel17-Jul-09 7:52 
AnswerRe: Delegates - I don't Get It Pin
harold aptroot17-Jul-09 8:14
harold aptroot17-Jul-09 8:14 
AnswerRe: Delegates - I don't Get It Pin
CodingYoshi17-Jul-09 8:20
CodingYoshi17-Jul-09 8:20 
GeneralRe: Delegates - I don't Get It Pin
eddieangel17-Jul-09 8:35
eddieangel17-Jul-09 8:35 
GeneralRe: Delegates - I don't Get It Pin
DaveyM6917-Jul-09 10:47
professionalDaveyM6917-Jul-09 10:47 
GeneralRe: Delegates - I don't Get It Pin
eddieangel17-Jul-09 11:00
eddieangel17-Jul-09 11:00 
GeneralRe: Delegates - I don't Get It Pin
DaveyM6917-Jul-09 11:26
professionalDaveyM6917-Jul-09 11:26 
GeneralRe: Delegates - I don't Get It Pin
DaveyM6917-Jul-09 11:39
professionalDaveyM6917-Jul-09 11:39 

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.