How to insert a range of elements into a list with C#

1 Answer

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

public class Program
{
    public static void Main() {
        var list = new List<string>() { "c#", "vb.net", "java" };
        
        list.InsertRange(1, new string[] { "c", "c++" });

        Console.WriteLine(string.Join(" ", list));
    }
}





/*
run:

c# c c++ vb.net java

*/

 



answered Mar 8, 2023 by avibootz
edited Mar 8, 2023 by avibootz

Related questions

1 answer 137 views
1 answer 159 views
159 views asked Aug 4, 2018 by avibootz
1 answer 212 views
1 answer 99 views
1 answer 138 views
...