Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created June 16, 2016 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/79608e80e1915ecdb5df118a54001086 to your computer and use it in GitHub Desktop.
Save jianminchen/79608e80e1915ecdb5df118a54001086 to your computer and use it in GitHub Desktop.
LINQ Lambda expression select - practice 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LINQ_Select_ToList
{
class Program
{
/*
* source code from:
* https://msdn.microsoft.com/en-us/library/bb342261(v=vs.100).aspx
*/
static void Main(string[] args)
{
getOutput();
}
/*
* Learn Lambda expression
* Debug - complain that lambda expression cannot be used
*
*/
static void getOutput()
{
string[] fruits = { "apple", "passionfruit", "banana", "mango",
"orange", "blueberry", "grape", "strawberry" };
List<int> lengths = fruits.Select(fruit => fruit.Length).ToList();
foreach (int length in lengths)
{
Console.WriteLine(length);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment