Convert code to utility or extension method

Is it possible to simplifing this piece of code with some static utility or extension method?
cachedDisplayInitialPinCodeSequence
.SetAutoKill(false)
.OnKill(() => cachedDisplayInitialPinCodeSequence = null);

cachedShowCorrectValidationStatusSequence
.SetAutoKill(false)
.OnKill(() => cachedShowCorrectValidationStatusSequence = null);
cachedDisplayInitialPinCodeSequence
.SetAutoKill(false)
.OnKill(() => cachedDisplayInitialPinCodeSequence = null);

cachedShowCorrectValidationStatusSequence
.SetAutoKill(false)
.OnKill(() => cachedShowCorrectValidationStatusSequence = null);
5 Replies
Ice_trooper
Ice_trooper2y ago
I cannot do this
Brady Kelly
Brady Kelly2y ago
OK, it looks like it's simply against to rules to do what you're trying. Why is t a ref parameter when you could maybe use the return value of NullifyOnKill and assign that to whatever t is in the calling code? Just a guess
Ice_trooper
Ice_trooper2y ago
I want to nullify that passed variable, that's why it's passed with ref keyword
Brady Kelly
Brady Kelly2y ago
I know that but you can't do that in a lambda, is why I'm proposing you don't pass the variable but use the return value instead and assign that return value to whatever you previously would have passed
Servator
Servator2y ago
You need to create a delegate After that you can use ref t
Want results from more Discord servers?
Add your server
More Posts