How to convert list to StringBuilder in C#

1 Answer

0 votes
using System;
using System.Text;
using System.Collections.Generic;

public static class Module1
{
    public static void Main()
    {
        List<string> lst = new List<string>() { "python", "c", "c++", "c#", "java" };

        StringBuilder sb = new StringBuilder();
        foreach (string s in lst) {
            sb.Append(s).Append(" ");
        }

        Console.WriteLine(sb);
    }
}




/*
run:
 
python c c++ c# java 

*/ 

 



answered Nov 18, 2021 by avibootz

Related questions

1 answer 179 views
1 answer 138 views
138 views asked Sep 10, 2020 by avibootz
1 answer 177 views
3 answers 370 views
370 views asked Feb 24, 2015 by avibootz
1 answer 100 views
1 answer 129 views
1 answer 122 views
...