Click here to Skip to main content
15,902,715 members
Home / Discussions / C#
   

C#

 
GeneralRe: Reflection: Getting property name from property itself [modified] Pin
PIEBALDconsult14-Jan-08 8:55
mvePIEBALDconsult14-Jan-08 8:55 
GeneralRe: Reflection: Getting property name from property itself Pin
GazzaJ14-Jan-08 23:39
GazzaJ14-Jan-08 23:39 
GeneralRe: Reflection: Getting property name from property itself Pin
DaveyM6914-Jan-08 23:56
professionalDaveyM6914-Jan-08 23:56 
GeneralRe: Reflection: Getting property name from property itself Pin
PIEBALDconsult15-Jan-08 12:03
mvePIEBALDconsult15-Jan-08 12:03 
GeneralRe: Reflection: Getting property name from property itself [modified] Pin
PIEBALDconsult15-Jan-08 12:54
mvePIEBALDconsult15-Jan-08 12:54 
GeneralRe: Reflection: Getting property name from property itself Pin
NassosReyzidis15-Jan-08 22:41
NassosReyzidis15-Jan-08 22:41 
QuestionIComparer Sorting multiple properties. Pin
Vijay Kulavade14-Jan-08 5:02
Vijay Kulavade14-Jan-08 5:02 
GeneralRe: IComparer Sorting multiple properties. Pin
Luc Pattyn14-Jan-08 5:40
sitebuilderLuc Pattyn14-Jan-08 5:40 
Hi,

if you want to sort in a special way, you need to create a class that implements IComparer,
which means it provides a method int Compare (Object x, Object y) where you first cast
x and y to the appropriate class, then perform the comparison the way you want it.

Example, assuming the collection holds instances of class Person:

class MyPersonComparer: IComparer {
  int Compare(object x, object y) {
    Person p1=(Person)x;
    Person p2=(Person)y;
    int diff=string.compare(p1.LastName, p2.LastName);      // highest priority field first
    if (diff==0) diff=string.compare(p2.FirstName, p1.FirstName); // reverse sort order
    return diff;
  }
}


BTW: you could embed the Compare method inside an existing class (e.g. Person itself).

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.


GeneralRe: IComparer Sorting multiple properties. Pin
Vijay Kulavade14-Jan-08 7:23
Vijay Kulavade14-Jan-08 7:23 
Generalput a folder Pin
angels77714-Jan-08 4:35
angels77714-Jan-08 4:35 
GeneralRe: put a folder Pin
Pete O'Hanlon14-Jan-08 5:12
mvePete O'Hanlon14-Jan-08 5:12 
GeneralRe: put a folder Pin
angels77714-Jan-08 14:04
angels77714-Jan-08 14:04 
GeneralRe: put a folder Pin
Pete O'Hanlon14-Jan-08 22:25
mvePete O'Hanlon14-Jan-08 22:25 
GeneralRe: put a folder Pin
DaveyM6914-Jan-08 23:36
professionalDaveyM6914-Jan-08 23:36 
GeneralHttpRequest object for a Web Reference API Pin
Skippums14-Jan-08 4:05
Skippums14-Jan-08 4:05 
QuestionC# readonly reference (like C++ const reference ) Pin
Zeinpresiyo14-Jan-08 3:26
Zeinpresiyo14-Jan-08 3:26 
GeneralRe: C# readonly reference (like C++ const reference ) Pin
Justin Perez14-Jan-08 3:45
Justin Perez14-Jan-08 3:45 
GeneralRe: C# readonly reference (like C++ const reference ) Pin
PIEBALDconsult14-Jan-08 4:13
mvePIEBALDconsult14-Jan-08 4:13 
GeneralRe: C# readonly reference (like C++ const reference ) Pin
PIEBALDconsult14-Jan-08 4:18
mvePIEBALDconsult14-Jan-08 4:18 
GeneralRe: C# readonly reference (like C++ const reference ) Pin
DavidNohejl14-Jan-08 4:56
DavidNohejl14-Jan-08 4:56 
AnswerRe: C# readonly reference (like C++ const reference ) Pin
Zeinpresiyo14-Jan-08 6:12
Zeinpresiyo14-Jan-08 6:12 
GeneralRe: C# readonly reference (like C++ const reference ) Pin
Pete O'Hanlon14-Jan-08 9:53
mvePete O'Hanlon14-Jan-08 9:53 
GeneralRe: C# readonly reference (like C++ const reference ) Pin
Zeinpresiyo17-Jan-08 0:04
Zeinpresiyo17-Jan-08 0:04 
Questiondeleting a file in use Pin
Ofori Boadu14-Jan-08 3:06
Ofori Boadu14-Jan-08 3:06 
GeneralRe: deleting a file in use Pin
benjymous14-Jan-08 3:13
benjymous14-Jan-08 3:13 

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.