Re: The System.Collections.Generic namespace

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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



.



Relevant Pages

  • Re: The System.Collections.Generic namespace
    ... I would like to implement the following code written in java using c# ... The problem when trying to convert this type of code is that the sort ... I see) to sort in c# is to declare a concrete class and not an ... public void op { ...
    (microsoft.public.dotnet.languages.csharp)
  • The System.Collections.Generic namespace
    ... I would like to implement the following code written in java using c# ... The problem when trying to convert this type of code is that the sort ... I see) to sort in c# is to declare a concrete class and not an ... public void op { ...
    (microsoft.public.dotnet.languages.csharp)
  • how to call a function
    ... Hello, completely new to Java. ... public void sort{ ... How do I call the sort function?? ... it gives me error saying ...
    (comp.lang.java.programmer)
  • Re: Sortable Java Tree Table
    ... I have never actually done this, but if I wanted to sort a JTree, ... private Listener listener = new Listener; ... public Object getChild(Object parent, int index) { ... public void valueForPathChanged{ ...
    (comp.lang.java.gui)
  • Re: Java Applet pulled from VMS Web Server
    ... anything to work and 2) I will go to my grave before deploying a "Java ... to use FTP as the protocol to upload the .JAR applet ... private String host; ... public void update { ...
    (comp.os.vms)