주 메뉴 열기

wwiki β

Lambda expressions 편집하기

경고: 로그인하지 않았습니다. 편집을 하면 IP 주소가 공개되게 됩니다. 로그인하거나 계정을 생성하면 편집자가 사용자 이름으로 기록되고, 다른 장점도 있습니다.

편집을 되돌릴 수 있습니다. 이 편집을 되돌리려면 아래의 바뀐 내용을 확인한 후 저장해주세요.
최신판 당신의 편집
39번째 줄: 39번째 줄:
 
Func<int, int> square = (x) => x*x;
 
Func<int, int> square = (x) => x*x;
 
Cosole.Write(square(10)); // 100출력
 
Cosole.Write(square(10)); // 100출력
</syntaxhighlight><syntaxhighlight lang="c#">
 
// Declare a Func variable and assign a lambda expression to the
 
// variable. The method takes a string and converts it to uppercase.
 
Func<string, string> selector = str => str.ToUpper();
 
 
// Create an array of strings.
 
string[] words = { "orange", "apple", "Article", "elephant" };
 
// Query the array and select strings according to the selector method.
 
IEnumerable<String> aWords = words.Select(selector);
 
 
// Output the results to the console.
 
foreach (String word in aWords)
 
    Console.WriteLine(word);
 
 
/*
 
This code example produces the following output:
 
 
ORANGE
 
APPLE
 
ARTICLE
 
ELEPHANT
 
 
*/
 
 
</syntaxhighlight>'Expression lambda'는 '[[Expression trees|expression tree]]' 타입으로 변환할 수 있다. <syntaxhighlight lang="csharp">
 
</syntaxhighlight>'Expression lambda'는 '[[Expression trees|expression tree]]' 타입으로 변환할 수 있다. <syntaxhighlight lang="csharp">
 
System.Linq.Expressions.Expression<Func<int, int>> e = x => x * x;
 
System.Linq.Expressions.Expression<Func<int, int>> e = x => x * x;
67번째 줄: 44번째 줄:
 
// Output:
 
// Output:
 
// x => (x * x)
 
// x => (x * x)
</syntaxhighlight>
+
</syntaxhighlight><br />
 
== Expression lambdas(식 람다) ==
 
== Expression lambdas(식 람다) ==
 
블록이 없는 람다<syntaxhighlight lang="c#">
 
블록이 없는 람다<syntaxhighlight lang="c#">

wwiki에서의 모든 기여는 다른 기여자가 편집, 수정, 삭제할 수 있다는 점을 유의해 주세요. 만약 여기에 동의하지 않는다면, 문서를 저장하지 말아 주세요.
또한, 직접 작성했거나 퍼블릭 도메인과 같은 자유 문서에서 가져왔다는 것을 보증해야 합니다 (자세한 사항은 Wwiki:저작권 문서를 보세요). 저작권이 있는 내용을 허가 없이 저장하지 마세요!

취소 편집 도움말 (새 창에서 열림)