Click here to Skip to main content
16,005,038 members
Home / Discussions / C#
   

C#

 
Questionsorting an ArrayList with different attributes Pin
Mostafa Siraj4-Dec-06 10:48
Mostafa Siraj4-Dec-06 10:48 
AnswerRe: sorting an ArrayList with different attributes Pin
Christian Graus4-Dec-06 11:09
protectorChristian Graus4-Dec-06 11:09 
GeneralRe: sorting an ArrayList with different attributes Pin
Mostafa Siraj4-Dec-06 11:19
Mostafa Siraj4-Dec-06 11:19 
GeneralRe: sorting an ArrayList with different attributes Pin
led mike4-Dec-06 11:24
led mike4-Dec-06 11:24 
GeneralRe: sorting an ArrayList with different attributes Pin
Mostafa Siraj4-Dec-06 11:27
Mostafa Siraj4-Dec-06 11:27 
GeneralRe: sorting an ArrayList with different attributes Pin
Christian Graus4-Dec-06 11:29
protectorChristian Graus4-Dec-06 11:29 
GeneralRe: sorting an ArrayList with different attributes Pin
Mostafa Siraj4-Dec-06 11:32
Mostafa Siraj4-Dec-06 11:32 
GeneralRe: sorting an ArrayList with different attributes Pin
Christian Graus4-Dec-06 11:42
protectorChristian Graus4-Dec-06 11:42 
OK, it's pretty simple

public class SamplesArrayList
{
public class Test : IComparable
{
public enum SortBy { SortByX, SortByY };

private SortBy _sortOrder;
public SortBy
{
get { return _sortOrder; }
set { _sortOrder = value; }
}

public int x;

public int y;
//this is the variable which i want to sort the list with it also

public Test(int x)
{
this.x = x;
}
int IComparable.CompareTo(object x)
{
Test x1 = (Test)x;

switch(SortOrder)
{
int result;

case SortBy.SortByX:
result = (this.x.CompareTo(x1.x));
break;
case SortBy.SortByY:
result = (this.y.CompareTo(x1.y));
break;
default:
throw new ArgumentException("The SortBy enum has been added to, but the CompareTo method has not been updated");
break;
}

return result;
}
}

Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog

GeneralRe: sorting an ArrayList with different attributes Pin
sanjaybs20014-Dec-06 21:06
sanjaybs20014-Dec-06 21:06 
GeneralRe: sorting an ArrayList with different attributes Pin
Christian Graus4-Dec-06 23:14
protectorChristian Graus4-Dec-06 23:14 
AnswerRe: sorting an ArrayList with different attributes Pin
Russell Jones4-Dec-06 21:02
Russell Jones4-Dec-06 21:02 
QuestionAccessViolationException was Handled Pin
Pokkri4-Dec-06 10:02
Pokkri4-Dec-06 10:02 
AnswerRe: AccessViolationException was Handled Pin
Christian Graus4-Dec-06 10:12
protectorChristian Graus4-Dec-06 10:12 
GeneralRe: AccessViolationException was Handled Pin
Pokkri5-Dec-06 1:08
Pokkri5-Dec-06 1:08 
QuestionFast loading images to a ImageList... Pin
Marcos Hernandez4-Dec-06 8:43
Marcos Hernandez4-Dec-06 8:43 
AnswerRe: Fast loading images to a ImageList... [modified] Pin
Luc Pattyn4-Dec-06 9:08
sitebuilderLuc Pattyn4-Dec-06 9:08 
GeneralRe: Fast loading images to a ImageList... Pin
Marcos Hernandez4-Dec-06 9:46
Marcos Hernandez4-Dec-06 9:46 
GeneralRe: Fast loading images to a ImageList... Pin
Luc Pattyn4-Dec-06 10:13
sitebuilderLuc Pattyn4-Dec-06 10:13 
GeneralRe: Fast loading images to a ImageList... Pin
Marcos Hernandez4-Dec-06 10:15
Marcos Hernandez4-Dec-06 10:15 
QuestionPlease Help me!!!Thanks !!! Pin
vandaivn4-Dec-06 8:21
vandaivn4-Dec-06 8:21 
AnswerRe: Please Help me!!!Thanks !!! Pin
Not Active4-Dec-06 9:30
mentorNot Active4-Dec-06 9:30 
AnswerRe: Please Help me!!!Thanks !!! Pin
Guffa4-Dec-06 10:44
Guffa4-Dec-06 10:44 
Questionhow to add excel like autofilters to datagrid header using c#.net Pin
nalla484-Dec-06 7:20
nalla484-Dec-06 7:20 
QuestionUsing .NET to call Matlab, How to pass array of strings? Pin
Woody Davis4-Dec-06 7:12
Woody Davis4-Dec-06 7:12 
QuestionExposing Children From Persistent Storage Pin
Christian M Jensen4-Dec-06 6:59
Christian M Jensen4-Dec-06 6:59 

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.