I need to figure out a way of using an if statement to determi开发者_Python百科ne whether a method in my code has been called, in order to perform an action. Is this possible in C#?
I'm not sure I understand the problem?
class MyClass {
  private bool m_myFunctionCalled = false;
  public void myFunction() {
    m_myFunctionCalled = true;
    return;
  }
}
public class MyClass
{
     private bool myFuncWasCalled = false;
     public void MyFunc()
     {
          myFuncWasCalled=true;      
     }
     public bool WasMyFuncCalled()
     {
        return myFuncWasCalled;
     }
     public void anotherFunc()
     {
          if(myFuncWasCalled)
          {
            // do some action
          }               
     }
}
See how to use it in this linqpad-programm

Yes, just make the method return something at the end.
For example:
...
bool temp = MyFunction();
if (temp == true) {
   // true was returned
}
...
bool MyFunction() {
   return true;
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论