728x90
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class NewBehaviourScript : MonoBehaviour
{
delegate void MyDelegate<T1, T2>(T1 a, T2 b); // void의 경우 action을 이용
// MyDelegate<int, int> MyDelegate; 기존의 델리게이크 사용방법
Action<int, int> MyDelegate2;
Func<int, int, string> MyDelegate3;
// Start is called before the first frame update
void Start()
{
MyDelegate3 = (int a, int b) => { int sum = a + b; return sum + "이 리턴되었습니다."; };//Func
print(MyDelegate3(3,5));
}
// Update is called once per frame
void Update()
{
}
}
728x90
'유니티로 배우는 c#' 카테고리의 다른 글
코루틴 (0) | 2021.10.12 |
---|---|
예외 처리 (0) | 2021.10.11 |
람다식 (0) | 2021.10.11 |
형식 매개 변수 T (0) | 2021.10.10 |
인터페이스 (0) | 2021.10.10 |