473,320 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Sorting NameObjectCollectionBase

Hello,

I am working with a class with a basetype of NameObjectCollection,
which has as a member an object array
public object[] Objects {get {return BaseGetAllValues();}}

which I want to sort before using....

I know I can do do a rough quivalent by feeding that into a new
ArrayList and then sorting the array list and using it, but is there a
better way?

I couldn't find one, but perhaps someone could suggest one?

I tried to just give the individual object class an implementation of
IComparable, but that didn't work...the CompareTo method gets called
(as of course it does when using the ArrayList, so it wsan't a waste
of time), but the result doesn't get sorted. I can't even do it by
hand assigning the values.

NameObjectCollectionBase allv = myClass.Objects;
allv[0] = allv[1];

doesn't change allv[0], it doesn't throw an exception, but it doesn't
do anything, if I pass them to a method as ref parameters I get "a ref
or out argument must be an assignable variable" exception.

So, any suggestions or am I stuck doing the new
ArrayList(myclass.Objects); Or is that really the best way of doing
it?

--
J.Moreno

Aug 18 '07 #1
0 1252

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Billy Jacobs | last post by:
I am getting an error saying: Public Method BaseGet not found on Type 'clsRunCollection'. The error occurs on the call to Public Property Run. If I change the parameter to an integer it works...
1
by: Rein Petersen | last post by:
Hi Everyone! I hope someone may have experience serializing a NameObjectCollectionBase (System.Collections.Specialized) and can advise me as to why I receive this error (below) when I try to...
3
by: William Stacey [MVP] | last post by:
What is the deal with NameObjectCollectionBase? It allows duplication keys to be added to the hashtable using System; using System.Collections; using System.Collections.Specialized; ...
1
by: Mark Overstreet | last post by:
Hi, I have several custom collections that inherit from System.Collections.Specialized.NameObjectCollectionBase and I want to serialize and deserialize with the XMLSerializer object. This works...
2
by: Mark Overstreet | last post by:
I am writing custom collections for my business objects but I need support for the foreach construct. I also need key support so I am inheriting from NameObjectCollectionBase. I need to support...
1
by: V. | last post by:
Hi, I need to sort the object System.Collections.Specialized.NameObjectCollectionBase based on one property of the special object. Is there an easy way to do this? Thanks Vicky
3
by: Sam Marrocco | last post by:
I've created a collection class that inherits the NameObjectCollectionBase. I'd like to add a few functions, such as being able to insert a new item at an indexed or keyed location in the...
2
by: Sam Marrocco | last post by:
I've constructed a class that inherits the NameObjectCollectionBase class. All works well, but I'd like to shadow the GetEnumerator method so that it returns an actual value *instead of a...
2
by: Sam Marrocco | last post by:
I've created a collection class that inherits NameObjectCollectionBase (call it MyCollection). MyCollection is declared as serializable, and serializes fine. A cursory glance into the serialized...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.