c# - Set values on List<List> from other list -


classa { list<classb> list1;} classb { list<classc> list2;} classc { int id; } classd { int id; } list<classd> list3; 

i have method following signature:

setvalues (ref classa objecta, list<classd> list3) 

i want set some of properties on classc objects. classb has list of classc objects , want relate classc , classd id.

how can without linq? (expecting linq has performance defect (i'm using .net 3.5)

last edit

i aiming non-linq solution thinking performance, , i'm using 2 eachs alireza solution(dunno if made right call)

any better solution? ty

as bartoszkp said ref not needed. iterate through collections , nested collections:

setvalues (list<classb> list1, list<classc> list3) {     foreach(classb b in list1)     {        foreach(classc c in b.list2)        {           c.property1 = somevalue;// set property here           ....            ....           .... , similar things here        }     } } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -