See my comments a couple of threads down. You need to be crystal clear about what your hierarchy (and the internal relationships - parent/child/sibling/etc) represent, so you can clearly define your add/delete/move/whatever operations.
Yes, given that a hierarchical structure is involved, you will be up for recursion (or possibly an equivalent iteration). For a many-children "tree", search the big G or Wikip for "trie". That might just hand it to you on a platter.
No. .Net's garbage collector will clean up for me. If I remove a child, the fact that it still references its parent is irrelevant, as the child will be collected, and then it's no longer sitting on a reference.
I need to provide Move Up and Move Down functions.
I think Bob Janova's suggestion that you include in your Node-whatever base class a 'Parent field is the correct solution, and it will have so much additional functionality, in the long run, it's the "only" solution.
What you leave unspecified in your question are the interesting cases such as:
You wish to move up a child Node of a Parent Node:
a. assuming the Parent Node has other siblings prior to the the Node to be "promoted:" the "promoted node" then remains a sibling of the Parent node, but now precedes the prior sibling in the collection ?
b. assuming the node to be "promoted" is the first child of its Parent Node: the "promoted node" then becomes a sibling of its former Parent node, preceding its former Parent node in the collection ?
I think you can also easily see that you will need to think through other "edge cases" involving moving a Node "down" in the collection/tree.
Also consider that some tree data structures (in computer science algorithmic theory) are based on having a single root node from which all other Nodes descend, and other trees, as you see in the typical TreeView Control in .NET, are based on having an arbitrary collection in which any number of Nodes can be root-level.
Since you use the word "collection" here, I would assume you are allowing multiple root-nodes. In that case the top root-node cannot be moved up, and the last root-node cannot be moved down.
imho it's a useful convention to make the design choice that if the 'Parent field of a Node, in a collection-based tree, contains 'null, then the given Node is a "root-level" node.
Now if you are constructing your own "hierarchic visual display" of this collection/tree structure ... not using some existing TreeView control ... then ... welcome to recursion.
"Humans are amphibians ... half spirit and half animal ... as spirits they belong to the eternal world, but as animals they inhabit time. This means that while their spirit can be directed to an eternal object, their bodies, passions, and imaginations are in continual change, for to be in time, means to change. Their nearest approach to constancy, therefore, is undulation: the repeated return to a level from which they repeatedly fall back, a series of troughs and peaks.” C.S. Lewis
I have one web based application using vb.net codebehing. Now i have to convert this into C#.net. Can anyone help me how to convert whole vb.net web application into C#.net web application. My application has 110 pages so its not possible to convert one by one page. Is it possible to convert whole application ?
If you delete an internal node, what do you do with its children? Your code would leave them orphaned...
Depending on what the original structure is meant to represent, it need rebuilding in some way after a deletion (or maybe deletion should be disallowed for some nodes...)
We need more information from the OP to define then solve his problem.
I was thinking more in terms of structures like B-trees (used in database indexing, etc), where deleting a node involves reconnecting any fragments (and in the case of a B-tree) possibly rebalancing the tree.
The point remains that we need to understand the semantics of the structure in order to know what a delete should do.
This is Chandra and Good evening. My query is, i have one web page. In that web page i have GridView Control. At presnt i can able to export the data to Excel from Gridview control.I have also Charts control in the same Web Page which is displying sales information.
Here My Question is.. Is it possible to export the Chart control as well as Gridview data to Excel format.
Thanks for your information. Meanwhile in my case i can not hard code the chat names because i have different types of grids like CategoryInfo,SubcategoryInfo Info,ProductInfo, SalesInfo etc. These are all grids contains lot of records and Each Grid has 3 types of charts. In this case how can i approach.
I am doing a university website for my third year project using asp.net the website is only for university staff and registed students so when logging in password and user name need to be validated using the schools active directry this is my 1st website and i dont have any idea of active directry plz help