DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Zip Using LINQ In C#.net

03.27.2012
| 3752 views |
  • submit to reddit
        Zip using LINQ in C#.net

	var val1= new int[] { 1, 2, 3, 4, 5 };
	var val2= new int[] { 6, 7, 8, 9, 10 };
	var zipVal = val1.Zip(val2, (x, y) => (x + y));
	foreach (var val in zipVal)
	{
	    Console.WriteLine(val);
	}