티스토리 뷰
Anonymous Method와 Lambda Expression을 비교해보자.
Lambda Expression이 조금 더 단순해보인다.
Lambda Expression이 조금 더 단순해보인다.
using System;
namespace DelegateSample
{
class Program
{
static void Main(string[] args)
{
Human Tom = new Human();
// Anonymous Method
Tom.ActionDelegate += delegate(string text) { Console.WriteLine("Anonymous:" + text); };
// Lambda Expression
Tom.ActionDelegate += (string text) => Console.WriteLine("Lambda1:" + text);
Tom.ActionDelegate += text => Console.WriteLine("Lambda2:" + text);
Tom.ActionDelegate("Hello");
}
delegate void Action(string words);
class Human
{
public Action ActionDelegate;
}
}
}
namespace DelegateSample
{
class Program
{
static void Main(string[] args)
{
Human Tom = new Human();
// Anonymous Method
Tom.ActionDelegate += delegate(string text) { Console.WriteLine("Anonymous:" + text); };
// Lambda Expression
Tom.ActionDelegate += (string text) => Console.WriteLine("Lambda1:" + text);
Tom.ActionDelegate += text => Console.WriteLine("Lambda2:" + text);
Tom.ActionDelegate("Hello");
}
delegate void Action(string words);
class Human
{
public Action ActionDelegate;
}
}
}
'Code > C#' 카테고리의 다른 글
[C#] 간단한 Object Initializer 샘플 코드 (0) | 2008.02.11 |
---|---|
[C#] 간단한 Lambda Expression 샘플 코드 (0) | 2008.02.11 |
[C#] Extension Methods 사용법 (0) | 2008.02.11 |
[C#] const vs readonly (0) | 2008.02.11 |
PInvoke SetForegroundWindow Sample Code (0) | 2008.01.14 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 유틸리티
- AdSense감추기
- autohotkey
- AxWebBrowser
- .net framework
- Rollback Rx
- tagREADYSTATE
- ScreenHunter
- download.com
- WinAutomation
- c#
- 애드센스숨기기
- Service pack
- Sample Code
- registry
- Automation
- windows
- 애드센스감추기
- Microsoft
- 스크린캡쳐
- iTextSharp
- java
- Regular Expressions
- iText
- jre
- DotNetMagic
- AdSense숨기기
- Phalanger
- READYSTATE_COMPLETE
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
글 보관함