Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - sorting an iList help

Reply
 
Old 04-09-2009   #1 (permalink)
jvcoach23


 
 

sorting an iList help

I'm trying to figure out how to sort an iList in vb.net. Say i have a
collection that looks like
Private mvcLastName As String = Nothing
Private mvcFirstName As String = Nothing
Public Property LastName() As String
Get
Return mvcLastName
End Get
Set(ByVal pvalue As String)
mvcLastName = pvalue
End Set
End Property
Public Property FirstName() As String
Get
Return mvcFirstName
End Get
Set(ByVal pvalue As String)
mvcFirstName = pvalue
End Set
End Property

I'd like to know how to sort it by the property firstname or lastname and
either asc or desc. I've been looking around... but not able to get it
figured out.

thanks
hope someone can lend a hand

My System SpecsSystem Spec
Old 04-09-2009   #2 (permalink)
Cor Ligthert[MVP]


 
 

Re: sorting an iList help

Hi,

You can start here,

http://msdn.microsoft.com/en-us/libr...ctionbase.aspx

As it is about sorting then it is mostly easier to use a class build for
data.

For sorting anything else you need to implement the Icomparer interface
http://msdn.microsoft.com/en-us/libr...icomparer.aspx

Beside that you can use as well a generic list and generic Icomparer class,
because your properties have to be used as object in the non generic lists.

Sorting is something I don't like in Net as it is done in my idea in an
elite way.
This is especially when it is about more value types in one sort. (For you
it is not so difficult as you have a only strings)

A better place to ask this question is however

microsoft.public.dotnet.languages.vb

Cor

"jvcoach23" <jvcoach23@xxxxxx> wrote in message
news:B77A6248-2370-48A5-BC18-71292B9915F5@xxxxxx
Quote:

> I'm trying to figure out how to sort an iList in vb.net. Say i have a
> collection that looks like
> Private mvcLastName As String = Nothing
> Private mvcFirstName As String = Nothing
> Public Property LastName() As String
> Get
> Return mvcLastName
> End Get
> Set(ByVal pvalue As String)
> mvcLastName = pvalue
> End Set
> End Property
> Public Property FirstName() As String
> Get
> Return mvcFirstName
> End Get
> Set(ByVal pvalue As String)
> mvcFirstName = pvalue
> End Set
> End Property
>
> I'd like to know how to sort it by the property firstname or lastname and
> either asc or desc. I've been looking around... but not able to get it
> figured out.
>
> thanks
> hope someone can lend a hand
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Sorting Vista mail
RE: Sorting XML PowerShell
Sorting Live Mail
Sorting (again) PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46