|
-
Mar 16th, 2012, 03:38 PM
#3
Thread Starter
Lively Member
Re: Sorting a list of objects
 Originally Posted by Shaggy Hiker
Take a look in MSDN on the List.Sort method. You will see that there are a number of overloads for this method. One of them will work....but more on that in a minute.
If you are only EVER going to sort on that first property, then you should have the class implement the IComparer interface. It's pretty easy to do, but easy to forget, as well. Therefore, whenever I want to do that, I generally just go to MSDN and copy the sample that is found there and change it to suit. Once you have that interface implemented, the standard .Sort() method will sorth them correctly. .
OK -- Working on that. However my test program is failing on the first:
Code:
myList.Add(New myClass1("a0", "b0", 0))
It tells me "Object reference not set to an instance of an object."
Am I doing something wrong in my "New" method?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|