A
Adam
Hi,
I've got a class which contains a number of properties which in turn are
read from a database. For example:
class TData
public property firstName
<get and set here>
public property surname
<get and set here>
etc. etc.
end class
I use an iComparer to enable sorting of the arrayList, however currently I
need to create a new class (implementing iComparer) for each property I want
to sort by.
Each iComparer class is virtually the same, with the exception of the line:
return directCast(x, TItems).firstname.compareTo(directCast(y,
TItems).firstname)
(where x and y are objects passed into the "compare" function)
I'm looking for a way of creating a single iComparer class which to which I
can pass a variable name, and sort by that. If VB.net had a JavaScript
"Eval"-type function, I could do it with a:
eval ("directCast(x, TItems)."+propName+".compareTo(directCast(y,
TItems)."+propName+")")
Any ideas? (He says, wondering if he's made himself clear!!).
Thanks,
A.
I've got a class which contains a number of properties which in turn are
read from a database. For example:
class TData
public property firstName
<get and set here>
public property surname
<get and set here>
etc. etc.
end class
I use an iComparer to enable sorting of the arrayList, however currently I
need to create a new class (implementing iComparer) for each property I want
to sort by.
Each iComparer class is virtually the same, with the exception of the line:
return directCast(x, TItems).firstname.compareTo(directCast(y,
TItems).firstname)
(where x and y are objects passed into the "compare" function)
I'm looking for a way of creating a single iComparer class which to which I
can pass a variable name, and sort by that. If VB.net had a JavaScript
"Eval"-type function, I could do it with a:
eval ("directCast(x, TItems)."+propName+".compareTo(directCast(y,
TItems)."+propName+")")
Any ideas? (He says, wondering if he's made himself clear!!).
Thanks,
A.