csharp list add to list

Code Example - csharp list add to list

                
                        List<string> initialList = new List<string>();
// Put whatever you want in the initial list
List<string> listToAdd = new List<string>();
// Put whatever you want in the second list
initialList.AddRange(listToAdd);
                    
                
 

csharp adding to a list

                        
                                //Declaring that its a list
List<string> test = new List<string>(); 
test.Add("Hello")
                            
                        
 

how to add to a list csharp

                        
                                var list = new List<string>();
list.Add("Hello");
                            
                        
 

csharp add list to list

                        
                                using System;
using System.Collections.Generic;

namespace add_list
{
        static void Main(string[] args)
        {
            List<string> first = new List<string> { "do", "rey", "me" };
            List<string> second = new List<string> { "fa", "so", "la", "te" };
            first.AddRange(second);
            foreach(var e in first)
            {
                Console.WriteLine(e);

            }
        }
    }
}