[C#]event/add/remove语法糖使用方法
2020/08
21
23:08
public class EventTest : MonoBehaviour
{
public delegate void LogCallback();
void Start()
{
LogCallback callback = ()=>
{
Debug.Log("Call");
};
MyLog += callback;
MyLog -= callback;
MyLog -= callback;
MyLog += callback;
if (LogStack != null)
{
LogStack.Invoke();
}
}
private LogCallback LogStack;
public event LogCallback MyLog
{
add
{
LogStack += value;
}
remove
{
LogStack -= value;
}
}
}
CopyRights: The Post by BY-NC-SA For Authorization,Original If Not Noted,Reprint Please Indicate From 老刘@开发笔记
Post Link: [C#]event/add/remove语法糖使用方法
Post Link: [C#]event/add/remove语法糖使用方法