Is it possible to call a non-static function inside static function in C#?

Posted by djzmo on Stack Overflow See other posts from Stack Overflow or by djzmo
Published on 2009-06-27T16:07:56Z Indexed on 2010/03/23 23:13 UTC
Read the original article Hit count: 338

Filed under:
|

Is it possible to call a non-static function that uses a public non-static class inside a static function in C#?

public class MyProgram
{
    private Thread thd = new Thread(myStaticFunction);
    public AnotherClass myAnotherClass = new AnotherClass();

    public MyProgram()
    {
        thd.Start();
    }

    public static void myStaticFunction()
    {
        myNonStaticFunction();
    }

    private void myNonStaticFunction()
    {
        myAnotherClass.DoSomethingGood();
    }
}

Well, the invalid code like above is what I need.

Any idea?

© Stack Overflow or respective owner

Related posts about c#

Related posts about static