FUNC代表与参考变量 [英] Func delegate with ref variable

查看:128
本文介绍了FUNC代表与参考变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public object MethodName(ref float y)
{
//method
}

我定义函数求委托这个方法怎么办?

How do I defined a Func delegate for this method?

推荐答案

它不能由 Func键完成,但你可以自定义一个代表吧:

It cannot be done by Func but you can define a custom delegate for it:

public delegate object MethodNameDelegate(ref float y);

用法示例:

public object MethodWithRefFloat(ref float y)
{
    return null;
}

public void MethodCallThroughDelegate()
{
    MethodNameDelegate myDelegate = MethodWithRefFloat;

    float y = 0;
    myDelegate(ref y);
}

这篇关于FUNC代表与参考变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆