Nic*_*aro 0 c# parameters lambda interface .net-3.5
我目前正在尝试使用(可能)C# 的 Func 或 Action 类型来处理 lambda。
我想创建一个名为 IMyInterface 的接口,它定义了一个名为 CreateCRUD 的方法。这应该需要 5 个参数。第一个是字符串。接下来的四个是调用 create、read、update 和 delete 方法的函数。
interface IMyInterface
{
void CreateCRUD(string name, Action<void> createFunc, Action<void> readFunc, Action<void> updateFunc, Action<void> deleteFunc);
}
Run Code Online (Sandbox Code Playgroud)
四个函数定义不应带任何参数且不返回任何内容。上面的代码不能编译。请指出我正确的方向。
改用非泛型Action
。
interface IMyInterface
{
void CreateCRUD(string name, Action createFunc, Action readFunc, Action updateFunc, Action deleteFunc);
}
Run Code Online (Sandbox Code Playgroud)