Re: The System.Collections.Generic namespace
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 11 Jul 2006 13:42:59 -0400
Efi,
That's pretty much how you have to do it.
As a side note, your op is very inefficient. You are always resorting
the list after you add the item to the end. Instead of adding the item and
sorting it, you should call BinarySearch, and find the index that you should
add the item at, and then add it there.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
<fooshm@xxxxxxxxx> wrote in message
news:1152636597.930238.148920@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,
I would like to implement the following code written in java using c#
java:
public void op (List myList) {
...
myList.add(myObjecy);
Collections.sort(myList);
}
The problem when trying to convert this type of code is that the sort
method is not located outside the class, so the only way (the way that
I see) to sort in c# is to declare a concrete class and not an
interface, i.e.
c#:
public void op (List<Object> myList) {
...
myList.add(myObjecy);
myList.sort();
}
Is there any solution to this problem?
Thanks,
Efi
.
- Follow-Ups:
- Re: The System.Collections.Generic namespace
- From: fooshm
- Re: The System.Collections.Generic namespace
- References:
- The System.Collections.Generic namespace
- From: fooshm
- The System.Collections.Generic namespace
- Prev by Date: Re: Determining if external executable has completed
- Next by Date: Re: searching an IList?
- Previous by thread: The System.Collections.Generic namespace
- Next by thread: Re: The System.Collections.Generic namespace
- Index(es):
Relevant Pages
|