Well, my titling is a bit weird I guess. But let me explain my question.
I have a while loop
while( GetObj() == null || !GetObj().Initialized ){
doStuff();
}
It would be neat when GetObj()
isn't called twice per loop.
I've debugged it in another project to be sure that .NET do not avoid calling the method twice. But that isn't the case.
My actual question now is
Is there a simple way, to avoid calling GetObj()
twice in my loop condition?
This form is less concise, but possibly more readable.
var obj = GetObj();
while(obj == null || !obj.Initialized ){
doStuff();
obj = GetObj();
}
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