Click here to Skip to main content
15,796,456 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi guys i wounder if is tehre any solution to call a non static task in static method for example this is my non static task

C#
public async Task login(string user, string password)
        {

        }


and this is my static method

C#
public static void checker(string email, string password)
      {




          while (true)
          {
              login(email, password);
          }


      }


but it can't be called and i don't want to use classes for them .

What I have tried:

..................................................
Posted
Updated yesterday
v2
Comments
Richard MacCutchan yesterday    
You have tagged your question C++, C#, Python, so which is it?
Ashkan X yesterday    
yes that was a mistake sorry it's C#
Richard MacCutchan yesterday    
Well you cannot do it, since every non-static method or property can only be accessed through its owning object.
CPallini yesterday    
While you cannot, depending on your actual scenario there could be a workaround (for instance you can pass to the static method, the instance of the class).
Maciej Los yesterday    
:thumbsup:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900