visual studio - Iterate in order through a list of objects - vb.net -


i have list of objects named machines. every machine has "priority" property (uinteger). i'm trying pick machines list (i.e. add them list) in specific order (from lowest highest priority), till condition respected.

thus wanted know if following method works :

machinelist.sort(function(x, y) x.priority.compareto(y.priority)) each machin in machinelist             machinestodisablelist.addmachine(machin)             if [condition]                 exit             end if next 

the goal add machines second list lowest highest priority, , stop when it's enough. i'm not sure solution if i'll iterate in correct order result expected.

is ? or solution somewhere else ?

why not iterate through list ordered priority. this:

    dim machinelist new list(of machine)     dim machinestodisablelist new list(of machine)     machinelist.add(new machine {.priority = 6})     machinelist.add(new machine {.priority = 2})     machinelist.add(new machine {.priority = 10})      each machine in machinelist.orderby(function(x) x.priority)         machinestodisablelist.add(machine)         if [condition]             exit         end if     next 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -