- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
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
Advertisements