How can a non-static class call another non-static class's method?

前端 未结 4 701
傲寒
傲寒 2021-01-18 16:23

I have 2 classes both non-static. I need to access a method on one class to return an object for processing. But since both classes is non-static, I cant just call the metho

4条回答
  •  一生所求
    2021-01-18 16:48

    class Bar
    {
        /*...*/
    
        public void MethodCaller()
        {
            var x = new Foo();
            object y = x.MethodToCall();
        }
    }
    

    BTW, in general, objects don't have names.

提交回复
热议问题