대리자5 [C#]식트리 식트리란? 식을 트리로 표현한 자료구조 using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; namespace ConsoleApp16 { class Program { static void Main(string[] args) { /* 식트리 */ //1*2+(x-y) Expression const1 = Expression.Constant(1); Expression const2 = Expression.Constant(2); Expression leftExp = Expression.Multiply(con.. 2020. 6. 15. [C#]람다식(Action대리자 Action대리자: Func대리자와 거의 똑같지만 반환형식이 없음 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp16 { class Program { static void Main(string[] args) { /*Action람다식*/ Action act1 = () => Console.WriteLine("Action()"); act1(); int result = 0; Action act2= (x)=> result =x* x; act2(3); Console.WriteLine(re); Action act3 = (x.. 2020. 6. 15. [C#]람다식(Func대리자) 람다식이란? 익명 메소드를 만듦 매개변수목록 => 식 원래 () () = delegate (int a, int b) { return a + b; }; 변경>>> () ()= (int a, int b)=>a+b; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp16 { class Program { /*더 간편하게 무명함수 만들기 Func대리자*/ static void Main(string[] args) { Func func1 = () => 10; //입력 매개변수가 없으며, 무조건 10을 반환 Console.Wri.. 2020. 6. 15. [C#]대리자 체인 : 여러개의 메소드를 동시에 참조할 수 있음 using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; namespace ConsoleApp12 { class Program { delegate void ThereIsAsFire(string location); //ThereIsAsFire 대리자 선언 static void Call119(string location)//메소드선언 { Console.WriteLine.. 2020. 6. 12. 이전 1 2 다음