如题
比如 方法1:private void ReceiveData(){},可能还有其他方法,都是无返回值的;
要在方法2:private bool ConnectSocket(方法1){}中将方法1作为参数传递到方法2中去。
如何写?求个示例代码。
------解决方案--------------------------------------------------------
private void ReceiveData() { }
public delegate void fun();
private bool ConnectSocket(fun recieve)
{
return recieve != null;
}
public void bind()
{
fun f = new fun(ReceiveData);
ConnectSocket(f);
}
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
private bool ConnectSocket(Action a) { ... }
调用ConnectSocket(() => ReceiveData());
------解决方案--------------------------------------------------------
delegate