Func delegate with ref variable

c#, c#-3.0, delegates, func, reference

Solution

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

public delegate object MethodNameDelegate(ref float y);

Usage example:

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

public void MethodCallThroughDelegate()
{
    MethodNameDelegate myDelegate = MethodWithRefFloat;

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

Problem

``` public object MethodName(ref float y) { // elided } ``` How do I define a `Func` delegate for this method?

Original source