how to call static method inside non static method in c#

前端 未结 4 951
隐瞒了意图╮
隐瞒了意图╮ 2021-01-24 05:58

how to call static method inside non static method in c# ?

Interviewer gave me scenario :

class class1
{

    pub         


        
4条回答
  •  情深已故
    2021-01-24 07:00

    if you call the method in the some class you just call it like this

        public void method2()
        {
            method1();  
    
        }
    

    but if it should been called from another class you have to precede it with the name of the class

    public void method2()
            {
                class1.method1();  
    
            }
    

提交回复
热议问题