예 : 설명 :
는 문자열 매개 변수를 수락하고 정수를 반환하는 커미션입니다.
public class MyClass { public int Method1(string input) { // 执行某些操作 return 0; } public int Method2(string input) { // 执行不同的操作 return 1; } public bool RunTheMethod(Func<string, int> myMethodName) { int result = myMethodName("我的字符串"); return true; } public bool Test() { return RunTheMethod(Method1); } }
위 내용은 C#에서 메소드를 매개 변수로 전달하려면 어떻게해야합니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!