Q:

combine two lists c#

List<string> a = new List<string>();
List<string> b = new List<string>();

a.AddRange(b);
0
class Program

    {
        static void Main(string[] args)
        {
            ArrayList CountryList1 = new ArrayList();
            ArrayList CountryList2 = new ArrayList();

            CountryList1.Add("Pakistan");
            CountryList1.Add("Nepal");
            CountryList2.Add("Butan");
            CountryList2.Add("Srilanka");
          
            CountryList1.AddRange(CountryList2);
        }

    }
0
var list3 = list1.Concat(list2);

// or

var list4 = list1.Union(list2);
// Union is a set operation - it returns distinct values.

// Concat simply returns the items from the first sequence followed by the items from the second sequence; the resulting sequence can include duplicate items.

// You can think of Union as Concat followed by Distinct.
0

New to Communities?

Join the community