Hey everyone,
Using C#, I need to do some extra work if function A()
was called right before function C()
. If any other function was called in between A()
and C()
then I don't want to do that extra work. Any ideas that would require the least amount of code duplication?
I'm trying to avoid adding lines like flag = false;
into every function B1
..BN
.
Here is a very basic example:
bool flag = false;
void A()
{
flag = true;
}
void B1()
{
...
}
void B2()
{
...
}
void C()
{
if (flag)
{
//do something
}
}
The above example was just using a simple case but I'm open to using something other than booleans. The important thing is that I want to be able to set and reset a flag of sorts so that C()
knows how to behave accordingly.
Thank you for your help. If you require clarification I will edit my post.