Which C# data structure is best/feasible to store hierarchical data

Baskar Lingam Ramachandran

I have below data structure:

enter image description here

Which C# data structure is best to store and retrieve these easily?

I want to be able to refer to Dev, Dev.Value1, Dev.Key1, Test, Test.Key1, so on..

Update: I have a json file and as I parse it I get these values. So the number of environments (Dev, Test) will be more like ( Dev, Test, UAT, Stable, Prod). Also the number of Key, Value pairs will be different in each environment. I need to store them separately in a structure to consume them later. As I parse the json I will get an environment (Dev) and all its key, values pairs and then I will get Test followed by all its key, value pairs.

Nino

You can make class like this...

public class Environment
{
    Dictionary<string, string> KeyValueData { get; set; }
    public string Name { get; set; }
    public Environment(string name)
    {
        Name = name;
        KeyValueData = new Dictionary<string, string>();
    }

    public void AddNewData(string key, string value)
    {
        this.KeyValueData.Add(key, value);
    }
}

Usage:

List<Environment> environments = new List<Environment>();
Environment env = new Environment("Test");
env.AddNewData("key1", "value1");
env.AddNewData("key2", "value2");
env.AddNewData("key3", "value3");

Environment env2 = new Environment("Prod");
env2.AddNewData("key1", "value1");
env2.AddNewData("key2", "value2");
env2.AddNewData("key3", "value3");
//...
environments.Add(env2);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to store hierarchical structure data in java?

From Dev

Query hierarchical data structure in firebase

From Dev

C# Data structure to store items in a hierarchical way that once a branch is built, it allows me to retrieve it and add it as part of another one

From Dev

Converting datatable into hierarchical data structure (JSON) using C#

From Dev

C: Read a file and store them into a data structure

From Dev

Structure to store data

From Dev

How to show hierarchical data structure with RecycleView?

From Dev

How to show hierarchical data structure with RecycleView?

From Dev

Obtaining mysql to get hierarchical data structure

From Dev

Sorting Closure Table Hierarchical Data Structure

From Dev

Better way to store hierarchical data with known depth?

From Dev

How to store hierarchical data within Firebase

From Dev

Convert a POJO to Tree structure in Java 8 for representation of data in hierarchical structure

From Dev

Data structure to store HashMap in Druid

From Dev

Data structure to store ip addresses

From Dev

Store tree data structure in database

From Dev

Data Structure to store a model information using Objective C and GLKit

From Dev

When to use which Data Structure?

From Dev

Not sure which data structure to use

From Dev

Which type of data structure is a stack?

From Dev

Suggest Data Structure which implement this

From Dev

c++ set data structure which keeps inserted order

From Dev

Which data structure to use for fast search? (C#)

From Dev

Which data structure in C++ suits to implement webbrowser history?

From Dev

Which data structure to use for fast search? (C#)

From Dev

Data structure to store data subject to keys

From Dev

Best data structure to store peculiarly structured data

From Dev

How to serialize a data structure which is instance of Data?

From Dev

How to define DDD Aggregate root for hierarchical data structure?

Related Related

  1. 1

    How to store hierarchical structure data in java?

  2. 2

    Query hierarchical data structure in firebase

  3. 3

    C# Data structure to store items in a hierarchical way that once a branch is built, it allows me to retrieve it and add it as part of another one

  4. 4

    Converting datatable into hierarchical data structure (JSON) using C#

  5. 5

    C: Read a file and store them into a data structure

  6. 6

    Structure to store data

  7. 7

    How to show hierarchical data structure with RecycleView?

  8. 8

    How to show hierarchical data structure with RecycleView?

  9. 9

    Obtaining mysql to get hierarchical data structure

  10. 10

    Sorting Closure Table Hierarchical Data Structure

  11. 11

    Better way to store hierarchical data with known depth?

  12. 12

    How to store hierarchical data within Firebase

  13. 13

    Convert a POJO to Tree structure in Java 8 for representation of data in hierarchical structure

  14. 14

    Data structure to store HashMap in Druid

  15. 15

    Data structure to store ip addresses

  16. 16

    Store tree data structure in database

  17. 17

    Data Structure to store a model information using Objective C and GLKit

  18. 18

    When to use which Data Structure?

  19. 19

    Not sure which data structure to use

  20. 20

    Which type of data structure is a stack?

  21. 21

    Suggest Data Structure which implement this

  22. 22

    c++ set data structure which keeps inserted order

  23. 23

    Which data structure to use for fast search? (C#)

  24. 24

    Which data structure in C++ suits to implement webbrowser history?

  25. 25

    Which data structure to use for fast search? (C#)

  26. 26

    Data structure to store data subject to keys

  27. 27

    Best data structure to store peculiarly structured data

  28. 28

    How to serialize a data structure which is instance of Data?

  29. 29

    How to define DDD Aggregate root for hierarchical data structure?

HotTag

Archive