성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Java - How to use the Foreign Funct...
[정성태] 제가 큰 실수를 했군요. ^^; Delegate를 통한 Bein...
[정성태] Working with Rust Libraries from C#...
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
[정성태] "props[i].GetValue(props[i])" 코드에서 ...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>C# 9.0 - (8) 정적 익명 함수 (static anonymous functions)</h1> <p> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > C# 9.0 - (1) <a target='tab' href='https://github.com/dotnet/csharplang/issues/100'>대상으로 형식화된 new 식(Target-typed new expressions)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12363'>https://www.sysnet.pe.kr/2/0/12363</a> C# 9.0 - (2) <a target='tab' href='https://github.com/dotnet/csharplang/issues/1738'>localsinit 플래그 내보내기 무시(Suppress emitting localsinit flag)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12364'>https://www.sysnet.pe.kr/2/0/12364</a> C# 9.0 - (3) <a target='tab' href='https://github.com/dotnet/csharplang/issues/111'>람다 메서드의 매개 변수 무시(Lambda discard parameters)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12365'>https://www.sysnet.pe.kr/2/0/12365</a> C# 9.0 - (4) <a target='tab' href='https://github.com/dotnet/csharplang/issues/435'>원시 크기 정수(Native ints)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12366'>https://www.sysnet.pe.kr/2/0/12366</a> C# 9.0 - (5) <a target='tab' href='https://github.com/dotnet/csharplang/issues/1888'>로컬 함수에 특성 지정 가능(Attributes on local functions)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12372'>https://www.sysnet.pe.kr/2/0/12372</a> C# 9.0 - (6) <a target='tab' href='https://github.com/dotnet/csharplang/issues/191'>함수 포인터(Function pointers)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12374'>https://www.sysnet.pe.kr/2/0/12374</a> C# 9.0 - (7) <a target='tab' href='https://github.com/dotnet/csharplang/issues/2850'>패턴 일치 개선 사항(Pattern matching enhancements)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12383'>https://www.sysnet.pe.kr/2/0/12383</a> C# 9.0 - (8) <a target='tab' href='https://github.com/dotnet/csharplang/issues/275'>정적 익명 함수 (static anonymous functions)</a> ; https://www.sysnet.pe.kr/2/0/12389 C# 9.0 - (9) <a target='tab' href='https://github.com/dotnet/csharplang/issues/39'>레코드 (Records)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12392'>https://www.sysnet.pe.kr/2/0/12392</a> C# 9.0 - (10) <a target='tab' href='https://github.com/dotnet/csharplang/issues/2460'>대상으로 형식화된 조건식(Target-typed conditional expressions)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12399'>https://www.sysnet.pe.kr/2/0/12399</a> C# 9.0 - (11) <a target='tab' href='https://github.com/dotnet/csharplang/issues/2844'>공변 반환 형식(Covariant return types)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12402'>https://www.sysnet.pe.kr/2/0/12402</a> C# 9.0 - (12) <a target='tab' href='https://github.com/dotnet/csharplang/issues/3194'>foreach 루프에 대한 GetEnumerator 확장 메서드 지원(Extension GetEnumerator)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12403'>https://www.sysnet.pe.kr/2/0/12403</a> C# 9.0 - (13) <a target='tab' href='https://github.com/dotnet/csharplang/blob/master/proposals/csharp-9.0/module-initializers.md'>모듈 이니셜라이저(Module initializers)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12404'>https://www.sysnet.pe.kr/2/0/12404</a> C# 9.0 - (14) <a target='tab' href='https://github.com/dotnet/csharplang/blob/master/proposals/csharp-9.0/extending-partial-methods.md'>부분 메서드에 대한 새로운 기능(New features for partial methods)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12405'>https://www.sysnet.pe.kr/2/0/12405</a> C# 9.0 - (15) <a target='tab' href='https://github.com/dotnet/csharplang/blob/master/proposals/csharp-9.0/top-level-statements.md'>최상위 문(Top-level statements)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12406'>https://www.sysnet.pe.kr/2/0/12406</a> C# 9.0 - (16) <a target='tab' href='https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/unconstrained-type-parameter-annotations'>제약 조건이 없는 형식 매개변수 주석(Unconstrained type parameter annotations)</a> ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12423'>https://www.sysnet.pe.kr/2/0/12423</a> </pre> <br /> <hr style='width: 50%' /><br /> <br /> (이번 실습은 - 오늘 기준 16.7.7의 Visual Studio 2019에서는 컴파일이 안 되고 "16.8.x"의 Preview 버전에서 가능합니다.)<br /> <br /> C# 7.0에 <a target='tab' href='https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/local-functions'>로컬 함수(Local function)</a>가 추가되고, C# 8.0에 <a target='tab' href='https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8#static-local-functions'>로컬 함수의 static 정의</a>가 가능해졌는데요. 마찬가지로 (C# 3.0부터 있었던) <a target='tab' href='https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/lambda-expressions'>람다 식</a>과 (C# 2.0부터 있었던) <a target='tab' href='https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/delegate-operator'>익명 메서드</a>에 (이제서야) static 정의를 할 수 있게 되었습니다.<br /> <br /> 기능은 동일하게, 람다 및 익명 메서드 내에서 외부 scope의 변수를 명시적으로 캡처하지 못하게 만드는 역할을 합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > using System; class Program { static void Main(string[] args) { { string title = "console: "; Func<int, string> func = <span style='color: blue; font-weight: bold'>static</span> i => { // Error CS8820 A static anonymous function cannot contain a reference to 'title'. // return title + i.ToString(); return i.ToString(); }; Console.WriteLine(func(10)); } { const string title = "console: "; Func<int, string> func = <span style='color: blue; font-weight: bold'>static</span> delegate (int i) { // const 변수의 경우 참조에 대한 부작용이 없으므로 사용 가능 return <span style='color: blue; font-weight: bold'>title</span> + i.ToString(); }; Console.WriteLine(func(10)); } } } </pre> <br /> (<a target='tab' href='https://www.sysnet.pe.kr/bbs/DownloadAttachment.aspx?fid=1647&boardid=331301885'>첨부 파일은 이 글의 예제 코드를 포함</a>합니다.)<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
4265
(왼쪽의 숫자를 입력해야 합니다.)