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 189 views
1 answer 147 views
147 views asked Sep 10, 2020 by avibootz
1 answer 185 views
3 answers 387 views
387 views asked Feb 24, 2015 by avibootz
1 answer 109 views
1 answer 139 views
1 answer 135 views
...