Concat Method in C#


To concat lists in C#, ue the Concat method.

The following is the list −

var list1 = new List<int>{12, 40};
var list2 = new List<int>{98, 122, 199, 230};

Here is the Concat method −

var res = list1.Concat(list2);

The following is the example to work with Concat method −

Example

 Live Demo

using System.Collections.Generic;
using System.Linq;
using System;

public class Demo {
   public static void Main() {

      // two lists
      var list1 = new List<int>{12, 40};
      var list2 = new List<int>{98, 122, 199, 230};
   
      // concat
      var res = list1.Concat(list2);

      foreach(int i in res) {
         Console.WriteLine(i);
      }
   }
}

Output

12
40
98
122
199
230

Updated on: 22-Jun-2020

155 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements