I am a C # man and got this argument from a website in php. It needs to be implemented in C #.
$ items = array (); While ($ row = mysql_fetch_assoc ($ query)) {parent ID $ pkey = $ row ['parent_id']; // child id $ ckey = $ row ['category_id']; // Store this $ items [$ pkey] ['kids'] [$ ckey] = $ line ['Category name']; } // Make our list $ first = true; // Create our list list ($ item, $ first); Function createList ($ array, $ first) {// We need access to the original array global $ objects; // First is a flag that is the first thing in this array // We use this flag so that you do not need to use createList ($ array [0] ['children'] in the initial list. $ First) {$ array = $ array [0] ['children'];} echo "& lt; ol>; \ n"; Foreign currency (dollar array = $ value = $ value) {$ key} If you have children of this item, show them (isset ($ item [$ key] ['children'])) {echo "\ n "; Build list ($ item [$ key] ['children'], wrong); // Tat $ first false!} Echo " \ n";} resonant "& lt; / ol & gt; \ n";
}
Is this a 3-dimensional array or hashtable in the last line above? It seems that its a hefty reason [$ Paki] ['children'] [$ ckey] is annoying me ..
Can anyone convert the above code to C #? I really appreciate PHP (and some other languages) use the dictionary (Associated Arrays) as the universal data. In Iacpi, Array ()
is a built-in dictionary structure, which can be nested, which can be nested.
In C #, the code will not be written using the same code, rather strongly typed data structures, that means that in PHP code you can add the key-value of Associative Array instead of member variable , Create individual classes to represent these data structures.
Comments
Post a Comment