I'm pretty sure that is possible (at least in java it is) and I'm C# beginner.
So I have a function which includes a callback (notify some other method that some work is finished).
I don't want to call another function because I'm losing a parameter there (and can't pass parameters in callback functions). How can I do everything in the same function?
What I'm doing now:
public static Tween Play(Tween tweenToPlay)
{
return tweenToPlay.Play().OnComplete(RewindCallback);
}
private static void RewindCallback()
{
// Execute some code after Tween is completed
}
What I actually want:
public static Tween Play(Tween tweenToPlay)
{
return tweenToPlay.Play().OnComplete(/*Create a function that will execute here*/);
}
Do you mean a lambda expression, like this?
public static Tween Play(Tween tweenToPlay)
{
return tweenToPlay
.Play()
.OnComplete(() => {
// Do stuff
});
}
You just want an anonymous method?
public static Tween Play(Tween tweenToPlay)
{
return tweenToPlay.Play().OnComplete(() =>
{
//... your code
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With