how to convert key value pairs in tabular form in asp.net [on hold]











up vote
-2
down vote

favorite












Dictionary<int, string> ht = new Dictionary<int, string>();

ht.Add(1, "Akshay");
ht.Add(2, "Hari");
ht.Add(3, "Raghvan");
ht.Add(4, "Milind");


Required output in tablular form:



key|value



1 | Akshay



2 | Hari



3 | Raghvan



4 | Milind



I want to convert this into tabular form. How can I do this?










share|improve this question









New contributor




Unknown is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as unclear what you're asking by Igor, Owen Pauling, Rob, S.Akbari, Stephen Muecke 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 8




    what tablular form?
    – Rahul
    Nov 19 at 10:08






  • 2




    plz show your expected output?
    – er-shoaib
    Nov 19 at 10:14










  • I assume he wants some sort of .csv /.tsv output, where a tab is the seperator (or the pipe character)
    – Marco
    Nov 19 at 13:06















up vote
-2
down vote

favorite












Dictionary<int, string> ht = new Dictionary<int, string>();

ht.Add(1, "Akshay");
ht.Add(2, "Hari");
ht.Add(3, "Raghvan");
ht.Add(4, "Milind");


Required output in tablular form:



key|value



1 | Akshay



2 | Hari



3 | Raghvan



4 | Milind



I want to convert this into tabular form. How can I do this?










share|improve this question









New contributor




Unknown is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as unclear what you're asking by Igor, Owen Pauling, Rob, S.Akbari, Stephen Muecke 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 8




    what tablular form?
    – Rahul
    Nov 19 at 10:08






  • 2




    plz show your expected output?
    – er-shoaib
    Nov 19 at 10:14










  • I assume he wants some sort of .csv /.tsv output, where a tab is the seperator (or the pipe character)
    – Marco
    Nov 19 at 13:06













up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











Dictionary<int, string> ht = new Dictionary<int, string>();

ht.Add(1, "Akshay");
ht.Add(2, "Hari");
ht.Add(3, "Raghvan");
ht.Add(4, "Milind");


Required output in tablular form:



key|value



1 | Akshay



2 | Hari



3 | Raghvan



4 | Milind



I want to convert this into tabular form. How can I do this?










share|improve this question









New contributor




Unknown is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











Dictionary<int, string> ht = new Dictionary<int, string>();

ht.Add(1, "Akshay");
ht.Add(2, "Hari");
ht.Add(3, "Raghvan");
ht.Add(4, "Milind");


Required output in tablular form:



key|value



1 | Akshay



2 | Hari



3 | Raghvan



4 | Milind



I want to convert this into tabular form. How can I do this?







c# asp.net asp.net-mvc






share|improve this question









New contributor




Unknown is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Unknown is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 19 at 12:48





















New contributor




Unknown is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 19 at 10:05









Unknown

134




134




New contributor




Unknown is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Unknown is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Unknown is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as unclear what you're asking by Igor, Owen Pauling, Rob, S.Akbari, Stephen Muecke 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






put on hold as unclear what you're asking by Igor, Owen Pauling, Rob, S.Akbari, Stephen Muecke 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 8




    what tablular form?
    – Rahul
    Nov 19 at 10:08






  • 2




    plz show your expected output?
    – er-shoaib
    Nov 19 at 10:14










  • I assume he wants some sort of .csv /.tsv output, where a tab is the seperator (or the pipe character)
    – Marco
    Nov 19 at 13:06














  • 8




    what tablular form?
    – Rahul
    Nov 19 at 10:08






  • 2




    plz show your expected output?
    – er-shoaib
    Nov 19 at 10:14










  • I assume he wants some sort of .csv /.tsv output, where a tab is the seperator (or the pipe character)
    – Marco
    Nov 19 at 13:06








8




8




what tablular form?
– Rahul
Nov 19 at 10:08




what tablular form?
– Rahul
Nov 19 at 10:08




2




2




plz show your expected output?
– er-shoaib
Nov 19 at 10:14




plz show your expected output?
– er-shoaib
Nov 19 at 10:14












I assume he wants some sort of .csv /.tsv output, where a tab is the seperator (or the pipe character)
– Marco
Nov 19 at 13:06




I assume he wants some sort of .csv /.tsv output, where a tab is the seperator (or the pipe character)
– Marco
Nov 19 at 13:06












1 Answer
1






active

oldest

votes

















up vote
0
down vote













One way to solve this is to use .Aggregate():



Dictionary<int, string> ht = new Dictionary<int, string>();

ht.Add(1, "Akshay");
ht.Add(2, "Hari");
ht.Add(3, "Raghvan");
ht.Add(4, "Milind");

var seperator = " | ";
//var seperator = "t";

var result = ht.Aggregate(new StringBuilder("Key | Value"), (a,b) => {
a.Append(Environment.NewLine);
a.Append(b.Key + seperator + b.Value);
return a;
});
result.ToString().Dump();


Output:



Key | Value
1 | Akshay
2 | Hari
3 | Raghvan
4 | Milind


If you are looking for one of the best explanations of what is actually happening here: LINQ Aggregate algorithm explained






share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    One way to solve this is to use .Aggregate():



    Dictionary<int, string> ht = new Dictionary<int, string>();

    ht.Add(1, "Akshay");
    ht.Add(2, "Hari");
    ht.Add(3, "Raghvan");
    ht.Add(4, "Milind");

    var seperator = " | ";
    //var seperator = "t";

    var result = ht.Aggregate(new StringBuilder("Key | Value"), (a,b) => {
    a.Append(Environment.NewLine);
    a.Append(b.Key + seperator + b.Value);
    return a;
    });
    result.ToString().Dump();


    Output:



    Key | Value
    1 | Akshay
    2 | Hari
    3 | Raghvan
    4 | Milind


    If you are looking for one of the best explanations of what is actually happening here: LINQ Aggregate algorithm explained






    share|improve this answer

























      up vote
      0
      down vote













      One way to solve this is to use .Aggregate():



      Dictionary<int, string> ht = new Dictionary<int, string>();

      ht.Add(1, "Akshay");
      ht.Add(2, "Hari");
      ht.Add(3, "Raghvan");
      ht.Add(4, "Milind");

      var seperator = " | ";
      //var seperator = "t";

      var result = ht.Aggregate(new StringBuilder("Key | Value"), (a,b) => {
      a.Append(Environment.NewLine);
      a.Append(b.Key + seperator + b.Value);
      return a;
      });
      result.ToString().Dump();


      Output:



      Key | Value
      1 | Akshay
      2 | Hari
      3 | Raghvan
      4 | Milind


      If you are looking for one of the best explanations of what is actually happening here: LINQ Aggregate algorithm explained






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        One way to solve this is to use .Aggregate():



        Dictionary<int, string> ht = new Dictionary<int, string>();

        ht.Add(1, "Akshay");
        ht.Add(2, "Hari");
        ht.Add(3, "Raghvan");
        ht.Add(4, "Milind");

        var seperator = " | ";
        //var seperator = "t";

        var result = ht.Aggregate(new StringBuilder("Key | Value"), (a,b) => {
        a.Append(Environment.NewLine);
        a.Append(b.Key + seperator + b.Value);
        return a;
        });
        result.ToString().Dump();


        Output:



        Key | Value
        1 | Akshay
        2 | Hari
        3 | Raghvan
        4 | Milind


        If you are looking for one of the best explanations of what is actually happening here: LINQ Aggregate algorithm explained






        share|improve this answer












        One way to solve this is to use .Aggregate():



        Dictionary<int, string> ht = new Dictionary<int, string>();

        ht.Add(1, "Akshay");
        ht.Add(2, "Hari");
        ht.Add(3, "Raghvan");
        ht.Add(4, "Milind");

        var seperator = " | ";
        //var seperator = "t";

        var result = ht.Aggregate(new StringBuilder("Key | Value"), (a,b) => {
        a.Append(Environment.NewLine);
        a.Append(b.Key + seperator + b.Value);
        return a;
        });
        result.ToString().Dump();


        Output:



        Key | Value
        1 | Akshay
        2 | Hari
        3 | Raghvan
        4 | Milind


        If you are looking for one of the best explanations of what is actually happening here: LINQ Aggregate algorithm explained







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 at 13:13









        Marco

        12.2k44176




        12.2k44176















            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

            How to fix TextFormField cause rebuild widget in Flutter