Hi all,
I'm using a SortedList to store data, and want the keys to be compared in
case insensitive order, so that
mySList["a"]
is the same as
mySList["A"]
I've run across the IComparable interface, but not sure how to implement.
Anyone know where I can find more info and samples?
Thanks,
Michael C., MCDBA 3 2802
I think you should just use normal Array and then implement IComparer
interface
There is a sample implementation in MSDN
---- here how they implment it ----
public class MyComparer: IComparer{
public int Comparer(object x, object y){
return(new CaseInsensitiveComparer(x,y));
}
}
--- here how I used it ---
string[] urArray = new string[]{"Come","age","Apple","Go"};
IComparer mc = new MyComparer();
Array.Sort(urArray, mc);
I just did it few day ago.
Cheers,
Kids
"Michael C" <mi******@nospam.org> wrote in message
news:jN****************@news4.srv.hcvlny.cv.net... Hi all,
I'm using a SortedList to store data, and want the keys to be compared in case insensitive order, so that
mySList["a"]
is the same as
mySList["A"]
I've run across the IComparable interface, but not sure how to implement. Anyone know where I can find more info and samples?
Thanks, Michael C., MCDBA
I'm using a SortedList and I need to sort by Key value.
Thanks,
Michael C., MCDBA
"kids_pro" <ki******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl... I think you should just use normal Array and then implement IComparer interface There is a sample implementation in MSDN ---- here how they implment it ---- public class MyComparer: IComparer{ public int Comparer(object x, object y){ return(new CaseInsensitiveComparer(x,y)); } } --- here how I used it --- string[] urArray = new string[]{"Come","age","Apple","Go"}; IComparer mc = new MyComparer();
Array.Sort(urArray, mc);
I just did it few day ago.
Cheers, Kids "Michael C" <mi******@nospam.org> wrote in message news:jN****************@news4.srv.hcvlny.cv.net... Hi all,
I'm using a SortedList to store data, and want the keys to be compared
in case insensitive order, so that
mySList["a"]
is the same as
mySList["A"]
I've run across the IComparable interface, but not sure how to
implement. Anyone know where I can find more info and samples?
Thanks, Michael C., MCDBA
Hmm try this way I haven't test it yet
public class MyComparer: IComparer{
public int Comparer(object x, object y){
SortedList a = (SortedList)x;
SortedList b = (SortedList)y;
return(new CaseInsensitiveComparer(a.Key,b.Key));
}
}
"Michael C" <mi******@nospam.org> wrote in message
news:V7******************@news4.srv.hcvlny.cv.net. .. I'm using a SortedList and I need to sort by Key value.
Thanks, Michael C., MCDBA
"kids_pro" <ki******@yahoo.com> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl... I think you should just use normal Array and then implement IComparer interface There is a sample implementation in MSDN ---- here how they implment it ---- public class MyComparer: IComparer{ public int Comparer(object x, object y){ return(new CaseInsensitiveComparer(x,y)); } } --- here how I used it --- string[] urArray = new string[]{"Come","age","Apple","Go"}; IComparer mc = new MyComparer();
Array.Sort(urArray, mc);
I just did it few day ago.
Cheers, Kids "Michael C" <mi******@nospam.org> wrote in message news:jN****************@news4.srv.hcvlny.cv.net... Hi all,
I'm using a SortedList to store data, and want the keys to be compared in case insensitive order, so that
mySList["a"]
is the same as
mySList["A"]
I've run across the IComparable interface, but not sure how to implement. Anyone know where I can find more info and samples?
Thanks, Michael C., MCDBA
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Zeng |
last post by:
Would someone know why SortedList doesn't work for these two keys?
System.Collections.SortedList.Add(Object key, Object value) +221
My code looks something like below, the...
|
by: Dennis C. Drumm |
last post by:
I have a class derived from a SortedList called SystemList that contains a
list of objects indexed with a string value.
The definition of the objects contained in the SortedList have a boolean...
|
by: Sean |
last post by:
How does one bind a SortedList to anything. If it cant be done why would
anyone ever even use a sortedlist?
We are currently (via business objects that use interfaces etc) binding
gridviews to...
|
by: Prez |
last post by:
I started writing .net code yesterday and I am grasping it well enough.
I have a few questions about SortedLists.
I am using managed C++ if that makes any difference.
Of the examples I...
|
by: SHEBERT |
last post by:
Here is an example of a SortedList that works as a datasource to the ComboBox
and a generic SortedList<that does not works as a datasource to the
ComboBox.
Why? If I use List and generic List<>,...
|
by: aeshiels |
last post by:
Hello,
I have a SortedList defined as...
SortedList<CUser, CUseruserList = new SortedList<CUser,
CUser>();
....and which to copy it to another sorted list
SortedList<CUser,...
|
by: Antonio Paglia |
last post by:
Hello. I have tried to insert this items into a SortedList.
dic = New SortedList
dic.Add("<<", "<<")
dic.Add("==", "==")
dic.Add(">>", ">>")
dic.Add("@@", "@@")
dic.Add("??", "??")
...
|
by: raylopez99 |
last post by:
I seem to get name collision between the Generic collection SortedList
and C++.NET Framework collection SortedList.
How to resolve? Here are the libraries that seem to clash:...
|
by: n3tx |
last post by:
Hi!
I have a problem with sortedlist, i guess i dont understand how it works.
I have a method called GetPublishingPlaces that returns an IList<PublishingPlace> (ex. contains 11 rows)
I want...
|
by: dcharnigo |
last post by:
I thought I would be tricky and force the SortedList to not sort using a custom IComparer, I used the following code, but when the list is sorting using the custom sort the accessors become unusable...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |