I have a C# function that look like this:
bool func(string name, bool retry)
{
string res= SomeOp(name);
if(res=="whatever")
{
return true;
}
else
{
if(retry)
return func(res, false)
}
return false;
}
I want the retry flag to be hidden from the user calling the function.
I need the function to be executed only twice.
I don’t want to make the function static, and I don’t want to declare an outside variable for this simple need., and a default value is not enough.
Is there is any other elegant solution?
You can do something like this