C#之Action的实际应用例子
2021-06-16 18:06
标签:cal 列表 frame 实际应用 ros rpd 技术分享 void ram public class DemoAction /// /// /// /// public class CSharpDemo : MonoBehaviour { Action action; DemoAction demo = new DemoAction(); List } // Update is called once per frame } /// /// /// } 运行结果如下图: C#之Action的实际应用例子 标签:cal 列表 frame 实际应用 ros rpd 技术分享 void ram 原文地址:https://www.cnblogs.com/wwwbdabc/p/10346446.html
{
public Action action;
public Action
public Action
public Action> action3;
/// 不带参数
///
public void ActionDemo()
{
if (action != null)
{
action();
}
}
/// 带一个参数
///
///
public void ActionDemo(int a)
{
if (action1 != null)
{
action1(a);
}
}
/// 带两个参数
///
///
///
public void ActionDemo(int a,string str)
{
if (action2 != null)
{
action2(a,str);
}
}
/// 带一个列表
///
///
public void ActionDemo(List
if (action3 != null)
{
action3(list);
}
}
}
// Use this for initialization
void Start () {
demo.action = TestAction;
demo.action1 = TestAction;
demo.action2 = TestAction;
demo.action3 = TestAction;
demo.action();
demo.action1(20);
demo.action2(20, "rose_grils");
demo.action3(list);
void Update () {
///
/// 不带参数
///
void TestAction(){
Debug.LogError(" 不带参数");
}
/// 带一个参数
///
///
void TestAction(int a)
{
Debug.LogError("带一个参数 = " + a);
}
/// 带2个参数
///
///
///
void TestAction(int a, string str)
{
Debug.LogError("带2个参数a = " + a + " str = " + str);
}
/// 带一个列表
///
///
void TestAction(List
{
Debug.LogError("带一个列表");
for (int i = 0; i {
Debug.LogError("i = " + list[i]);
}
}
---------------------
作者:穿梭在26个字母的世界
来源:CSDN
原文:https://blog.csdn.net/rose_girls/article/details/50152823