I have a dictionary with the following data:
Key Value
1 Introduction
1.1 General
1.1.1 Scope
1.2 Expectations
2 Background
2.1 Early Development
...
What I’d like to do is figure out a way – in C# – to create a new list (or append to an array) with the values concatenated based on the list-style key, like so:
Key Value Concatenation
1 Introduction Introduction
1.1 General Introduction - General
1.1.1 Scope Indroduction - General - Scope
1.2 Expectations Introduction - Expectations
2 Background Background
2.1 Early Development Background - Early Development
...
There is no set number of sublevels for the key but it will always be in numeric format. Any thoughts?
This obviously needs to be cleaned up and made more efficient, but you can do this pretty simply using a recursive method:
This would be called like this:
Needs lots of error handling as well; this obviously assumes a well-formed input. But you should be able to take it from here.