asp.net - Table into Tree Structure c# -



asp.net - Table into Tree Structure c# -

i have next info construction , wanting turn tree. have working recursion wondering if there more efficient/better way?

public class construction { public int id {get;set;} public int level1 {get;set;} public int level2 {get;set;} public int level3 {get;set;} public int level4 {get;set;} } var info = new list<structure> { new structure{id=1,level1=1,level2=11,level3=35,level4=105}, new structure{id=2,level1=1,level2=11,level3=35,level4=106}, new structure{id=3,level1=1,level2=11,level3=36,level4=107}, new structure{id=4,level1=1,level2=11,level3=36,level4=108}, new structure{id=5,level1=1,level2=11,level3=36,level4=109}, new structure{id=6,level1=1,level2=11,level3=36,level4=110}, new structure{id=7,level1=1,level2=11,level3=36,level4=111}, new structure{id=8,level1=2,level2=12,level3=37,level4=112}, new structure{id=9,level1=2,level2=12,level3=37,level4=113}, new structure{id=10,level1=2,level2=12,level3=37,level4=114}, new structure{id=11,level1=2,level2=12,level3=37,level4=115}, new structure{id=12,level1=2,level2=12,level3=37,level4=116}, new structure{id=13,level1=2,level2=12,level3=38,level4=117}, new structure{id=14,level1=2,level2=12,level3=39,level4=118}, new structure{id=15,level1=2,level2=12,level3=39,level4=119}, new structure{id=16,level1=2,level2=12,level3=40,level4=120}, new structure{id=17,level1=2,level2=12,level3=40,level4=121}, new structure{id=18,level1=2,level2=12,level3=40,level4=122}, new structure{id=19,level1=2,level2=12,level3=40,level4=123}, new structure{id=20,level1=2,level2=12,level3=40,level4=124}, new structure{id=21,level1=2,level2=12,level3=40,level4=125}, new structure{id=22,level1=2,level2=12,level3=41,level4=126}, new structure{id=23,level1=2,level2=12,level3=41,level4=127}, new structure{id=24,level1=3,level2=13,level3=42,level4=128}, new structure{id=25,level1=3,level2=13,level3=43,level4=129}, new structure{id=26,level1=3,level2=13,level3=44,level4=130}, new structure{id=27,level1=3,level2=13,level3=45,level4=131}, new structure{id=28,level1=3,level2=13,level3=45,level4=132}, new structure{id=29,level1=3,level2=13,level3=46,level4=133}, new structure{id=30,level1=3,level2=13,level3=47,level4=134}, new structure{id=31,level1=3,level2=13,level3=47,level4=135}, new structure{id=32,level1=3,level2=13,level3=47,level4=136}, new structure{id=33,level1=3,level2=13,level3=48,level4=137}, new structure{id=34,level1=3,level2=14,level3=49,level4=138}, new structure{id=35,level1=3,level2=14,level3=49,level4=141}, new structure{id=36,level1=3,level2=14,level3=49,level4=142}, new structure{id=37,level1=3,level2=14,level3=49,level4=143}, new structure{id=38,level1=3,level2=14,level3=49,level4=144}, new structure{id=39,level1=3,level2=14,level3=50,level4=145} }

so wanting output like:

1 - 11 - 35 - 105 - 106 - 36 - 107 - 108 - 109 - 110 - 111 ..... ..... ..... 3 - 14 - 49 - 138 - 141 - 142 - 143 - 144 - 50 - 145

i assume recursive solution have come using method recursion. if tree info construction deep run problems stack space. convert implicit recursion have explicit recursion within method using stack or similar.

there plenty of advice on how this, example:

eric lippert eric lippert phil haacked jon skeet

c# asp.net linq lambda

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -