I understand that the usual way of creating a strongly typed
collection is to inherit from CollectionBase. However, CollectionBase
does not support sorting. What is the best way to implement this?
Derive from ArrayList? 10 5170
_DS <_D*@Nospamforme.com> wrote: I understand that the usual way of creating a strongly typed collection is to inherit from CollectionBase. However, CollectionBase does not support sorting. What is the best way to implement this? Derive from ArrayList?
CollectionBase.InnerList returns an ArrayList, so you can sort that.
Of course, in 2.0 you probably wouldn't use CollectionBase in the first
place, but List<T>.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
"_DS" <_D*@Nospamforme.com> wrote in message
news:6q********************************@4ax.com... I understand that the usual way of creating a strongly typed collection is to inherit from CollectionBase. However, CollectionBase does not support sorting. What is the best way to implement this? Derive from ArrayList?
I honestly do not understand the thinking process of some people who post on
these groups.
This is how I would think:
1) I want to implement a strongly typed collection so I use CollectionBase
2) What does CollectionBase give me to help implement this? Oh. there's this
protected property called InnerList which gives access to the ArrayList used
to implement the collection.
3) I will implement Sort by calling InnerList.Sort()
I can't see how it could be any easier.
The hardest part is finding CollectionBase in the first place and even that
comes naturally from saying to yourself "I want to do collection stuff so
what is in the Collections namespace?"
I don't like to flame but RTFM dude - 99 times out of a 100 its quicker than
posting and you learn extra stuff beyond your particular problem of the
moment.
If you don't like to flame, then why do it?
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Nick Hounsome" wrote: "_DS" <_D*@Nospamforme.com> wrote in message news:6q********************************@4ax.com...I understand that the usual way of creating a strongly typed collection is to inherit from CollectionBase. However, CollectionBase does not support sorting. What is the best way to implement this? Derive from ArrayList?
I honestly do not understand the thinking process of some people who post on these groups.
This is how I would think:
1) I want to implement a strongly typed collection so I use CollectionBase 2) What does CollectionBase give me to help implement this? Oh. there's this protected property called InnerList which gives access to the ArrayList used to implement the collection. 3) I will implement Sort by calling InnerList.Sort()
I can't see how it could be any easier. The hardest part is finding CollectionBase in the first place and even that comes naturally from saying to yourself "I want to do collection stuff so what is in the Collections namespace?"
I don't like to flame but RTFM dude - 99 times out of a 100 its quicker than posting and you learn extra stuff beyond your particular problem of the moment.
_DS,
You will probably want to implement IComparable in the class for which you
are building the CollectionBase implementation - not in the collection but in
the class the collection will hold.
And there's nothing that says you couldn't then create your own Sort command
in your custom collection, but John is correct, there is one that you can use.
In either case, writing your own sort or using InnerList.Sort(), you should
implement IComparable so that the sort can do the comparisons that are
required.
HTH
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Jon Skeet [C# MVP]" wrote: _DS <_D*@Nospamforme.com> wrote: I understand that the usual way of creating a strongly typed collection is to inherit from CollectionBase. However, CollectionBase does not support sorting. What is the best way to implement this? Derive from ArrayList?
CollectionBase.InnerList returns an ArrayList, so you can sort that.
Of course, in 2.0 you probably wouldn't use CollectionBase in the first place, but List<T>.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too
Some suggested reading for you, Nick: http://www.dalepreston.com/Blog/2005...by-insult.html
HTH
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Nick Hounsome" wrote: "_DS" <_D*@Nospamforme.com> wrote in message news:6q********************************@4ax.com...I understand that the usual way of creating a strongly typed collection is to inherit from CollectionBase. However, CollectionBase does not support sorting. What is the best way to implement this? Derive from ArrayList?
I honestly do not understand the thinking process of some people who post on these groups.
This is how I would think:
1) I want to implement a strongly typed collection so I use CollectionBase 2) What does CollectionBase give me to help implement this? Oh. there's this protected property called InnerList which gives access to the ArrayList used to implement the collection. 3) I will implement Sort by calling InnerList.Sort()
I can't see how it could be any easier. The hardest part is finding CollectionBase in the first place and even that comes naturally from saying to yourself "I want to do collection stuff so what is in the Collections namespace?"
I don't like to flame but RTFM dude - 99 times out of a 100 its quicker than posting and you learn extra stuff beyond your particular problem of the moment.
One RTFM at the end of a post containing the answer to his question plus the
constructive advice about how to go about answering future questions hardly
constitutes motivation by insult.
Surely you must agree that to post without even looking up the members of
the class you are using indicates either laziness or poor problem solving
skills.
"Dale" <da******@nospam.nospam> wrote in message
news:AE**********************************@microsof t.com... Some suggested reading for you, Nick:
http://www.dalepreston.com/Blog/2005...by-insult.html
HTH -- Dale Preston MCAD C# MCSE, MCDBA
"Nick Hounsome" wrote:
"_DS" <_D*@Nospamforme.com> wrote in message news:6q********************************@4ax.com... >I understand that the usual way of creating a strongly typed > collection is to inherit from CollectionBase. However, CollectionBase > does not support sorting. What is the best way to implement this? > Derive from ArrayList?
I honestly do not understand the thinking process of some people who post on these groups.
This is how I would think:
1) I want to implement a strongly typed collection so I use CollectionBase 2) What does CollectionBase give me to help implement this? Oh. there's this protected property called InnerList which gives access to the ArrayList used to implement the collection. 3) I will implement Sort by calling InnerList.Sort()
I can't see how it could be any easier. The hardest part is finding CollectionBase in the first place and even that comes naturally from saying to yourself "I want to do collection stuff so what is in the Collections namespace?"
I don't like to flame but RTFM dude - 99 times out of a 100 its quicker than posting and you learn extra stuff beyond your particular problem of the moment.
On Sun, 29 Jan 2006 08:00:46 GMT, "Nick Hounsome" I honestly do not understand the thinking process of some people who post on these groups.
Here's my thinking process: You should find those guys who beat you
up on the playground and give them a good scolding. I do want to
thank you for my heightened appreciation for the Dale Prestons and
John Skeets of the world. Usenet would be a sorry place...
Dale and John, thanks again. I'll eventually move to generics, but I
had already written a class that derived from ArrayList and
implemented compare functions, etc. I was going to change to derive
from CollectionBase instead. I did miss the InnerList property,
partly as I was looking for functions. But more because I thought
that CollectionBase was further down in the inheritance hierarchy and
that ArrayList was derived from CollectionBase. I'll check into that.
"_DS" <_D*@Nospamforme.com> wrote in message
news:1j********************************@4ax.com... On Sun, 29 Jan 2006 08:00:46 GMT, "Nick Hounsome"I honestly do not understand the thinking process of some people who post on these groups. Here's my thinking process: You should find those guys who beat you up on the playground and give them a good scolding. I do want to thank you for my heightened appreciation for the Dale Prestons and John Skeets of the world. Usenet would be a sorry place...
Hypocrit! This is way more of a flame than I dished out. Dale and John, thanks again. I'll eventually move to generics, but I had already written a class that derived from ArrayList and implemented compare functions, etc. I was going to change to derive from CollectionBase instead. I did miss the InnerList property, partly as I was looking for functions.
Hopefully thanks to my comment you have now learned to look for protected
properties.
But more because I thought that CollectionBase was further down in the inheritance hierarchy and that ArrayList was derived from CollectionBase.
Why? Inheritance is shown quite clearly near the top of the doc page.
You are just proving my point that a few moments careful reading of the
documentation about a class is more time efficient than posting.
On Tue, 31 Jan 2006 08:09:33 GMT, "Nick Hounsome"
<nh***@nickhounsome.me.uk> wrote: "_DS" <_D*@Nospamforme.com> wrote in message news:1j********************************@4ax.com.. . On Sun, 29 Jan 2006 08:00:46 GMT, "Nick Hounsome"I honestly do not understand the thinking process of some people who post on these groups. Here's my thinking process: You should find those guys who beat you up on the playground and give them a good scolding. I do want to thank you for my heightened appreciation for the Dale Prestons and John Skeets of the world. Usenet would be a sorry place...
Hypocrit! This is way more of a flame than I dished out.
More of a flame than your "Read The Fucking Manual" rant? (or did you
not know what RTFM means). You can dish it out, I'll give you that.
Hopefully thanks to my comment you have now learned to look for protected properties.
Hopefully you'll try decaf. In the future, consider what you're
saying and please don't 'Help" me any more. I thought this group was
relatively free of flamers.
DS
"_DS" <_D*@nomail.com> wrote in message news:8f********************************@4ax.com... On Tue, 31 Jan 2006 08:09:33 GMT, "Nick Hounsome" <nh***@nickhounsome.me.uk> wrote:
"_DS" <_D*@Nospamforme.com> wrote in message news:1j********************************@4ax.com. ..
<snip>Hypocrit! This is way more of a flame than I dished out.
More of a flame than your "Read The Fucking Manual" rant? (or did you not know what RTFM means). You can dish it out, I'll give you that.
Perhaps he meant "Read the FINE Manual" and you just took it wrong?!?!
:^)
OK...I'll go away now
Bill This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: suz |
last post by:
Hey,
I have a collection with custom objects. That collection
is bounded to a listview (I used the article of Lhotka).
The listview is also sortable.
I have also textboxes bound to the same...
|
by: cedoucette |
last post by:
I just wrote code to support sortable columns in a datagrid.
It seems to work fine; but, it doesn't look right.
The problem is that I have a generic style for links
and a different style for the...
|
by: Jon |
last post by:
My application needs to present data generated at run time in a datagrid that
can be sorted by clicking on columns, and where rows can be selected and
events generated.
Do I need to set up a...
|
by: Pieter |
last post by:
Hi,
I made a Collection-class that inherits from
System.Collections.ObjectModel.Collection(Of T), but when I use this
collection as a DataSource of a DataGrid or a DataGridView, it isn't sorted...
|
by: TPhelps |
last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable
datagrid that works.
I want to change one of the columns to a hyperlink. The examples I find use
a bound column. I...
|
by: vincemoon |
last post by:
Sites such as download.com, dealtime.com, shopping.com, and tucows.com,
feature impressive sortable lists of products.
What software that imports CSV can be used to generate database-driven...
|
by: shellon |
last post by:
Hi all:
I want to convert the float number to sortable integer, like the
function float2rawInt() in java, but I don't know the internal
expression of float, appreciate your help!
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |