I have some variables which were given through ref
keyword in my function. I want to use ref-variables in lambda expression without using local variables exactly.
I know that C# can't merge lambdas and ref-variables in work. But doesn't exist any perversion to make ref-variables work in lambda-expression?
Pseudo-code (wanna-be C#):
T MyFunction<T>(ref T x, ref T y)
{
return (Func<T>) ( () => ( (100 * (x - y)) / x ) ();
}
I want it:
1). Be generic.
2). Accept as arguments the generic-types by references.
3). Using two options upper make it work with lambdas.
4). Return the result with using generic.
5). Be an organic-programming code :) Joke.
And call smth. like that:
int x = 21, y = 9;
int result = MyFunction<int>(ref x, ref y);
And with other types etc...
double x = 21.5, y = 9.3;
double result = MyFunction<double>(ref x, ref y);
Pity, that such constructions and desires C# couldn't give me, so I'm going to look at Lisp/Haskell ( maybe F# ).
(PS) => ("So I want to have a hard sex with C# possibilities exactly as you can see.")