Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7698003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:08:30+00:00 2026-05-31T22:08:30+00:00

I’ve made my own tree data structure via classes. Now I’m stuck with really

  • 0

I’ve made my own tree data structure via classes.
Now I’m stuck with really basic stuffs. I need to make output tab delimited file from data in my List <MainTreeNode>.
I think that recursion is only way?!

Tree is N-tree, and output have first row as header and other rows are values.

Tree:

  1. MSG (MainTreeNode)
    • MainParam (Must have prop NAME, doesn’t have to have prop VALUE)
      • SubParam1 (Must have prop NAME, must have prop VALUE)
      • SubParam2 (Must have prop NAME, doesn’t have to have prop VALUE)
        • SubSubParam2.1 (Must have prop NAME, must have prop VALUE)
          etc.

Or:

  1. Message : Name
    • Param1 : ValueV1 (VALUE must, because it doesn’t have children)
    • Param2
      • Param2.1 : ValueV2
      • Param2.2 : Value
        • Param2.2.1 : ValueV3
        • Param2.2.2 : ValueV4 …etc.

And output have to be like this (first line is header):

Param1|Param2/Param2.1|Param2/Param2.2/Param2.2.1|Param2/Param2.2/Param2.2.2  
ValueV1|ValueV2|ValueV3|ValueV4
...

So I need probably List for header and for values but I don’t know how to implement that in recursion way (or any another).

Some of unfinished code:

public void PrintToTabFile(List<Message> messages, List<string> parameters)
    {
        foreach (string s in parameters)
        {
            using (StreamWriter streamWriter = new StreamWriter(@"C:\temp\" + s + ".xls"))
            { 
                streamWriter.Write("No.\tMsgName\tMsgData1\tMsgData2\tMsgData3");
                var msg = messages.Where(x => x.Parameters.Where(p => p.ParameterName == s).Count() == 1);

                List<string> headers = new List<string>();
                List<string> values= new List<string>();
                //... Stuck!!!
            }
        }
    }

    private void Recursion(Parameter parameter, List<string> headers, List<string> values)
    {
        if (parameter.SubParameters.Count == 0)
        {
            int index = headers.IndexOf(parameter.ParameterName);
            values[index] = parameter.ParameterValue;
        }
        else
        {
            foreach (Parameter p in parameter.SubParameters)
            {
                Recursion(p, headers, values);
                //and Stuck Probably here or before recursion call
            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:08:31+00:00Added an answer on May 31, 2026 at 10:08 pm

    I won’t claim that I really know what you are asking, but still I’ll give it shot. To me this seems like a very basic recursion to traverse a tree structure with some weird output while you are doing it.
    Try it like this:
    1. Make an interface for all your classes called INode. This interface should contain the typical things like List Children, INode Parent etc.
    2. Make all your classes implement this interface (or let them inherit a base class that does this)
    3. Now start with your base clase and traverse recursively over all Children using the Children property and generate your output.

    This should do the trick I guess. (Sorry, no VS here to put up some real code)

    BTW: you’ll probably find a ton of posts about this on stackoverflow already.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
In my XML file chapters tag has more chapter tag.i need to display chapters
I need to clean up various Word 'smart' characters in user input, including but
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
I have thousands of HTML files to process using Groovy/Java and I need to
I'm parsing an XML file, the creators of it stuck in a bunch social

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.