Last active
May 31, 2022 04:57
-
-
Save satoyuichi/050558bce0a2f1b1d408992dc3d65938 to your computer and use it in GitHub Desktop.
if 文地獄対策
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
delegate bool ConditionCheck (); | |
class CheckAndAction { | |
public ConditionCheck check { get; set; }; | |
public Action action { get; set; }; | |
} | |
caList = new List<CheckAndAction> (); | |
caList.Add ( new CheckAndAction() { | |
check = () => { | |
// 条件を満しているかどうかで true か false を返す | |
return true; | |
}, | |
action = () => { | |
// 上の条件を満していた場合に実行する処理を書く | |
} | |
} | |
); | |
foreach (CheckAndAction ca in caList) | |
{ | |
if (ca.check ()) { | |
ca.action (); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment