Need help converting PHP to C#
I have this php code:

    $lines = file("data.csv");
    $nested = array();
    $links = array();
    
    // first, create a structure that contains the connections between elements
    foreach ($lines as $line) {
      list($child, $parent) = explode(",", $line);
      if ($child == $parent) {
        $nested[$parent] = null;
      } else {
        // add it to the children of parent
        $links[$parent][] = $child;
      }
    }
    
    function process(&$arr) {
      global $links;
      foreach ($arr as $key => $value) {
        // no more children => stop recursion
        if (!array_key_exists($key, $links)) {
          $array[$key] = null;
          continue;
        }
        // insert its children
        $arr[$key] = array_flip($links[$key]);
        // recurse down
        process($arr[$key]);
      }
    }
    
    
    function print_html($multi_dimensional_array)
    {
        $m = $multi_dimensional_array;
        $keys = array();
    
        foreach($m as $key=>$value) {
                $keys[] = $key;
        }
    
        $i = 0;
    
        while($i < count($multi_dimensional_array)) {
            echo '<li><a href="#">'.$keys[$i].'</a>';
            if(is_array($multi_dimensional_array[$keys[$i]])) {
                    echo '<ul>';
                    recursion($multi_dimensional_array[$keys[$i]]);
                    echo '</ul>';
            }
            echo '</li>';
            $i++;
        }
    }
    
    process($nested);
    
    print_html($nested);

The data.csv format is (value,parent), an example would be:

    one,one
    two,two
    three,three
    sub_one,one
    sub_one2,one
    sub_two,two
    sub_two2,two
    sub_two3,two
    sub_three,three
    sub_sub_one,sub_one
    sub_sub_one2,sub_one

Basically this what this PHP code does is create a multidimensional array that contains the parent name as key and the childs as values, and if a child also contains sub childs then it would be a key which contains subkeys, etc...

How could I use C# to do what this php code does?
Need help converting PHP to C#
===

I have this php code:

    $lines = file("data.csv");
    $nested = array();
    $links = array();
    
    // first, create a structure that contains the connections between elements
    foreach ($lines as $line) {
      list($child, $parent) = explode(",", $line);
      if ($child == $parent) {
        $nested[$parent] = null;
      } else {
        // add it to the children of parent
        $links[$parent][] = $child;
      }
    }
    
    function process(&$arr) {
      global $links;
      foreach ($arr as $key => $value) {
        // no more children => stop recursion
        if (!array_key_exists($key, $links)) {
          $array[$key] = null;
          continue;
        }
        // insert its children
        $arr[$key] = array_flip($links[$key]);
        // recurse down
        process($arr[$key]);
      }
    }
    
    
    function print_html($multi_dimensional_array)
    {
        $m = $multi_dimensional_array;
        $keys = array();
    
        foreach($m as $key=>$value) {
                $keys[] = $key;
        }
    
        $i = 0;
    
        while($i < count($multi_dimensional_array)) {
            echo '<li><a href="#">'.$keys[$i].'</a>';
            if(is_array($multi_dimensional_array[$keys[$i]])) {
                    echo '<ul>';
                    recursion($multi_dimensional_array[$keys[$i]]);
                    echo '</ul>';
            }
            echo '</li>';
            $i++;
        }
    }
    
    process($nested);
    
    print_html($nested);

The data.csv format is (value,parent), an example would be:

    one,one
    two,two
    three,three
    sub_one,one
    sub_one2,one
    sub_two,two
    sub_two2,two
    sub_two3,two
    sub_three,three
    sub_sub_one,sub_one
    sub_sub_one2,sub_one

Basically this what this PHP code does is create a multidimensional array that contains the parent name as key and the childs as values, and if a child also contains sub childs then it would be a key which contains subkeys, etc...

How could I use C# to do what this php code does?