C# Getting value from delegate methods inside a class --- ref with lambda operator?
<p>I want to encapsulate delegate methods, which will be invoked later on. This delegate method, when invoked, will calculate some arguments at that instance of time and assign/return the value to a variable outside of the class.</p>

<p>For example, I have a class Tool</p>

<p>This tool should generate, let's say Point, when the delegate method is called...</p>

<pre><code>public delegate void Action();

class Tool
{
public Action Select;
public Action Cancel;
public Point position;
public Tool(ref Point outPoint) //Cannot use ref with lambda...
{
Select = () =&gt; outPoint = position;
}

public void Update(Point newPosition)
{
position = newPosition
}
public void UpdateKey(Keys k, bool IsPress)
{
//Invoke Select/Cancel when press some keys
}

}
</code></pre>

<p>What I am trying to accomplish here is a simple function that should receive my input and fill it with correct argument after Select is invoked. If this was a single method, then it is easily done using ref. However, I have to keep track of many arguments, so I have to turn it into a class. Another thing is, this invocation happens inside the class, so I cannot return the calculated value from within the class. Even though I could change the design so that the update method is updated from outside of the class, what I desire is to have the class manages its own update routines. I know that there should be a better way, so if there is any, please tell me.</p>
