Created
June 16, 2016 17:21
-
-
Save jianminchen/79608e80e1915ecdb5df118a54001086 to your computer and use it in GitHub Desktop.
LINQ Lambda expression select - practice 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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