Select and map to another object

CSharp · Console

/Program.cs

using System;
using System.Linq;
					
public class Program
{
	public static void Main()
	{
		var people = new[]
		{
		   new {Id = 6000, Name = "Jennifer", Age = 21, City="London", Country = "United Kingdom", UserName = "jen123"}, 
		   new {Id = 6001, Name = "Alton", Age = 22, City="Paris", Country = "France", UserName = "alton_minton"},
		   new {Id = 6003, Name = "Milford", Age = 23, City="New York", Country = "United States", UserName = "53milford"}
		};

		var condensed = people.Select(person => new { Id = person.Id, Name = person.Name});
		
		foreach (var c in condensed)
		{
			Console.WriteLine(c);
		}
	}
}
;